Changeset: e49d6897d042 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e49d6897d042
Modified Files:
        gdk/gdk_bbp.c
        sql/test/emptydb/Tests/check.stable.out
        sql/test/emptydb/Tests/check.stable.out.32bit
        sql/test/emptydb/Tests/check.stable.out.int128
Branch: string_imprints
Log Message:

Merge with default


diffs (truncated from 6257 to 300 lines):

diff --git a/ctest/tools/monetdbe/example2.c b/ctest/tools/monetdbe/example2.c
--- a/ctest/tools/monetdbe/example2.c
+++ b/ctest/tools/monetdbe/example2.c
@@ -170,6 +170,20 @@ main(void)
        if ((err = monetdbe_cleanup_statement(mdbe, stmt)) != NULL)
                error(err)
 
+       /* NULL value version */
+       if ((err = monetdbe_prepare(mdbe, "SELECT b, t FROM test where t = ?; 
", &stmt, NULL)) != NULL)
+               error(err)
+       char *s2 = NULL;
+       if ((err = monetdbe_bind(stmt, s2, 0)) != NULL)
+               error(err)
+       if ((err = monetdbe_execute(stmt, &result, NULL)) != NULL)
+               error(err)
+       fprintf(stdout, "Query result with %zu cols and %"PRId64" rows\n", 
result->ncols, result->nrows);
+       if ((err = monetdbe_cleanup_result(mdbe, result)) != NULL)
+               error(err)
+       if ((err = monetdbe_cleanup_statement(mdbe, stmt)) != NULL)
+               error(err)
+
        if ((err = monetdbe_prepare(mdbe, "SELECT b, y FROM test where y = ?; 
", &stmt, NULL)) != NULL)
                error(err)
        char *y = "Hello";
@@ -183,6 +197,20 @@ main(void)
        if ((err = monetdbe_cleanup_statement(mdbe, stmt)) != NULL)
                error(err)
 
+       /* NULL value version */
+       if ((err = monetdbe_prepare(mdbe, "SELECT b, y FROM test where y = ?; 
", &stmt, NULL)) != NULL)
+               error(err)
+       char *y2 = NULL;
+       if ((err = monetdbe_bind(stmt, y2, 0)) != NULL)
+               error(err)
+       if ((err = monetdbe_execute(stmt, &result, NULL)) != NULL)
+               error(err)
+       fprintf(stdout, "Query result with %zu cols and %"PRId64" rows\n", 
result->ncols, result->nrows);
+       if ((err = monetdbe_cleanup_result(mdbe, result)) != NULL)
+               error(err)
+       if ((err = monetdbe_cleanup_statement(mdbe, stmt)) != NULL)
+               error(err)
+
        if (monetdbe_close(mdbe))
                error("Failed to close database")
        return 0;
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -728,6 +728,9 @@ BBPreadEntries(FILE *fp, unsigned bbpver
 
                if (buf[nread] != '\n' && buf[nread] != ' ') {
                        BATdestroy(bn);
+#ifdef GDKLIBRARY_HASHASH
+                       GDKfree(hbats);
+#endif
                        TRC_CRITICAL(GDK, "invalid format for BBP.dir on line 
%d", lineno);
                        return GDK_FAIL;
                }
@@ -736,6 +739,9 @@ BBPreadEntries(FILE *fp, unsigned bbpver
 
                if (snprintf(BBP_bak(bid), sizeof(BBP_bak(bid)), "tmp_%o", 
(unsigned) bid) >= (int) sizeof(BBP_bak(bid))) {
                        BATdestroy(bn);
+#ifdef GDKLIBRARY_HASHASH
+                       GDKfree(hbats);
+#endif
                        TRC_CRITICAL(GDK, "BBP logical filename directory is 
too large, on line %d\n", lineno);
                        return GDK_FAIL;
                }
@@ -754,6 +760,9 @@ BBPreadEntries(FILE *fp, unsigned bbpver
                        BBP_logical(bid) = GDKstrdup(logical);
                        if (BBP_logical(bid) == NULL) {
                                BATdestroy(bn);
+#ifdef GDKLIBRARY_HASHASH
+                               GDKfree(hbats);
+#endif
                                TRC_CRITICAL(GDK, "GDKstrdup failed\n");
                                return GDK_FAIL;
                        }
@@ -769,6 +778,9 @@ BBPreadEntries(FILE *fp, unsigned bbpver
                        BBP_options(bid) = GDKstrdup(options);
                        if (BBP_options(bid) == NULL) {
                                BATdestroy(bn);
+#ifdef GDKLIBRARY_HASHASH
+                               GDKfree(hbats);
+#endif
                                TRC_CRITICAL(GDK, "GDKstrdup failed\n");
                                return GDK_FAIL;
                        }
@@ -1424,6 +1436,7 @@ BBPinit(bool first)
 #ifdef GDKLIBRARY_HASHASH
        bat *hashbats = NULL;
        bat nhashbats = 0;
+       gdk_return res = GDK_SUCCEED;
 #endif
 
        /* the maximum number of BATs allowed in the system and the
@@ -1565,6 +1578,9 @@ BBPinit(bool first)
        if (BBPinithash(0, (bat) ATOMIC_GET(&BBPsize)) != GDK_SUCCEED) {
                TRC_CRITICAL(GDK, "BBPinithash failed");
                MT_lock_unset(&BBPnameLock);
+#ifdef GDKLIBRARY_HASHASH
+               GDKfree(hashbats);
+#endif
                return GDK_FAIL;
        }
        MT_lock_unset(&BBPnameLock);
@@ -1575,13 +1591,20 @@ BBPinit(bool first)
                gdk_return rc = BBPprepare(false);
                MT_lock_unset(&GDKtmLock);
                if (rc != GDK_SUCCEED) {
+#ifdef GDKLIBRARY_HASHASH
+                       GDKfree(hashbats);
+#endif
                        TRC_CRITICAL(GDK, "cannot properly prepare process 
%s.", BAKDIR);
                        return rc;
                }
        }
 
-       if (BBPcheckbats(bbpversion) != GDK_SUCCEED)
+       if (BBPcheckbats(bbpversion) != GDK_SUCCEED) {
+#ifdef GDKLIBRARY_HASHASH
+               GDKfree(hashbats);
+#endif
                return GDK_FAIL;
+       }
 
 #ifdef GDKLIBRARY_TAILN
        char *needstrbatmove;
@@ -1596,6 +1619,9 @@ BBPinit(bool first)
                        if (fd < 0) {
                                TRC_CRITICAL(GDK, "cannot create signal file 
needstrbatmove.\n");
                                GDKfree(needstrbatmove);
+#ifdef GDKLIBRARY_HASHASH
+                               GDKfree(hashbats);
+#endif
                                return GDK_FAIL;
                        }
                        close(fd);
@@ -1613,6 +1639,9 @@ BBPinit(bool first)
                        } else {
                                GDKsyserror("unexpected error opening %s\n", 
needstrbatmove);
                                GDKfree(needstrbatmove);
+#ifdef GDKLIBRARY_HASHASH
+                               GDKfree(hashbats);
+#endif
                                return GDK_FAIL;
                        }
                }
@@ -1620,8 +1649,11 @@ BBPinit(bool first)
 #endif
 
 #ifdef GDKLIBRARY_HASHASH
-       if (nhashbats > 0 && fixhashash(hashbats, nhashbats) != GDK_SUCCEED)
-               return GDK_FAIL;
+       if (nhashbats > 0)
+               res = fixhashash(hashbats, nhashbats);
+       GDKfree(hashbats);
+       if (res != GDK_SUCCEED)
+               return res;
 #endif
 
        if (bbpversion < GDKLIBRARY && TMcommit() != GDK_SUCCEED) {
@@ -1760,12 +1792,12 @@ heap_entry(FILE *fp, BAT *b, BUN size)
 {
        size_t free = b->theap->free;
        if (size < BUN_NONE) {
-               if ((b->ttype >= 0 && ATOMstorage(b->ttype) == TYPE_msk)) {
-                       BUN bytes = ((size + 31) / 32) * 4;
-                       if (free > bytes)
-                               free = bytes;
-               } else if (b->twidth > 0 && free / b->twidth > size)
+               if ((b->ttype >= 0 && ATOMstorage(b->ttype) == TYPE_msk))
+                       free = ((size + 31) / 32) * 4;
+               else if (b->twidth > 0)
                        free = size << b->tshift;
+               else
+                       free = 0;
        }
        return fprintf(fp, " %s %d %d %d " BUNFMT " " BUNFMT " " BUNFMT " "
                       BUNFMT " " OIDFMT " %zu %zu %d %" PRIu64" %" PRIu64,
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -813,6 +813,12 @@ HEAPload_intern(Heap *h, const char *nme
                h->base = GDKmalloc(h->size);
                h->wasempty = true;
        } else {
+               if (h->free == 0) {
+                       int fd = GDKfdlocate(h->farmid, nme, "wb", ext);
+                       if (fd >= 0)
+                               close(fd);
+                       h->wasempty = true;
+               }
                h->base = GDKload(h->farmid, nme, ext, h->free, &h->size, 
h->storage);
        }
        if (h->base == NULL)
diff --git a/monetdb5/mal/mal_module.c b/monetdb5/mal/mal_module.c
--- a/monetdb5/mal/mal_module.c
+++ b/monetdb5/mal/mal_module.c
@@ -64,6 +64,8 @@ getModules(void)
        int i;
        Module s,n;
 
+       if (!b)
+               return NULL;
        for( i = 0; i< MODULE_HASH_SIZE; i++){
                s = moduleIndex[i];
                while(s){
diff --git a/sql/ChangeLog b/sql/ChangeLog
--- a/sql/ChangeLog
+++ b/sql/ChangeLog
@@ -1,6 +1,12 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Thu Nov  4 2021 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
+- Removed deprecated system view sys.systemfunctions. It was marked
+  as deprecated from release Apr2019 (11.33.3).  Use query:
+    select id as function_id from sys.functions where system;
+  to get the same data as the old view.
+
 * Thu Oct 21 2021 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
 - Extended SQL system catalog with lookup table sys.fkey_actions and
   view sys.fkeys to provide user friendly querying of existing foreign
diff --git a/sql/backends/monet5/Tests/limithack.test 
b/sql/backends/monet5/Tests/limithack.test
--- a/sql/backends/monet5/Tests/limithack.test
+++ b/sql/backends/monet5/Tests/limithack.test
@@ -12,7 +12,7 @@ CREATE TABLE "sys"."tbls" (
 )
 
 statement ok
-COPY 40 RECORDS INTO "sys"."tbls" FROM stdin USING DELIMITERS E'\t',E'\n','"'
+COPY 39 RECORDS INTO "sys"."tbls" FROM stdin USING DELIMITERS E'\t',E'\n','"'
 <COPY_INTO_DATA>
 2001   "schemas"       2000    NULL    0       true    0       false   0
 2007   "types" 2000    NULL    0       true    0       false   0
@@ -53,7 +53,6 @@ 6380  "storagemodelinput"     2000    NULL    0       tru
 6428   "storagemodel"  2000    "create view sys.storagemodel as select * from 
sys.storagemodel();"     1       true    0       false   0
 6438   "tablestoragemodel"     2000    "-- A summary of the table storage 
requirement is is available as a table view.\n-- The auxiliary column denotes 
the maximum space if all non-sorted columns\n-- would be augmented with a hash 
(rare situation)\ncreate view sys.tablestoragemodel\nas select 
""schema"",""table"",max(count) as ""count"",\n\tsum(columnsize) as 
columnsize,\n\tsum(heapsize) as heapsize,\n\tsum(hashes) as 
hashes,\n\tsum(imprints) as imprints,\n\tsum(case when sorted = false then 8 * 
count else 0 end) as auxiliary\nfrom sys.storagemodel() group by 
""schema"",""table"";"   1       true    0       false   0
 6453   "statistics"    2000    NULL    0       true    0       false   0
-6616   "systemfunctions"       2000    NULL    0       true    0       false   0
 
 statement ok
 create function limited()
@@ -65,8 +64,8 @@ end
 query ITITIIIII rowsort
 select * from tbls where id in (select id from limited())
 ----
-6616
-systemfunctions
+6453
+statistics
 2000
 NULL
 0
diff --git a/sql/backends/monet5/sql_scenario.c 
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -470,13 +470,13 @@ SQLinit(Client c)
        /* initialize the database with predefined SQL functions */
        sqlstore *store = SQLstore;
        if (store->first == 0) {
-               /* check whether table sys.systemfunctions exists: if
-                * it doesn't, this is probably a restart of the
+               /* check whether last created object trigger 
sys.system_update_tables (from 99_system.sql) exists.
+                * if it doesn't, this is probably a restart of the
                 * server after an incomplete initialization */
                if ((msg = SQLtrans(m)) == MAL_SUCCEED) {
-                       sql_schema *s = mvc_bind_schema(m, "sys");
-                       sql_table *t = s ? mvc_bind_table(m, s, 
"systemfunctions") : NULL;
-                       if (t == NULL)
+                       /* TODO there's a going issue with loading triggers due 
to system tables,
+                          so at the moment check for existence of 'logging' 
schema from 81_tracer.sql */
+                       if (!mvc_bind_schema(m, "logging"))
                                store->first = 1;
                        msg = mvc_rollback(m, 0, NULL, false);
                }
@@ -504,8 +504,6 @@ SQLinit(Client c)
                                create trigger system_update_schemas after 
update on sys.schemas for each statement call sys_update_schemas(); \
                                create trigger system_update_tables after 
update on sys._tables for each statement call sys_update_tables(); \
                                update sys.functions set system = true; \
-                               create view sys.systemfunctions as select id as 
function_id from sys.functions where system; \
-                               grant select on sys.systemfunctions to public; \
                                update sys._tables set system = true; \
                                update sys.schemas set system = true; \
                                UPDATE sys.types     SET schema_id = (SELECT id 
FROM sys.schemas WHERE name = 'sys') WHERE schema_id = 0 AND schema_id NOT IN 
(SELECT id from sys.schemas); \
diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -292,103 +292,6 @@ sql_drop_functions_dependencies_Xs_on_Ys
 }
 
 static str
-sql_update_apr2019(Client c, mvc *sql, const char *prev_schema)
-{
-       size_t bufsize = 3000, pos = 0;
-       char *buf, *err;
-       sql_schema *s = mvc_bind_schema(sql, "sys");
-       sql_table *t;
-
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to