Changeset: bf10d72aa3ab for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bf10d72aa3ab
Modified Files:
        gdk/gdk_batop.c
        monetdb5/mal/mal_import.c
        sql/ChangeLog.Jun2020
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_upgrades.c
        sql/scripts/25_debug.sql
        sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64.int128
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128
        sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
        sql/test/emptydb/Tests/check.stable.out
        sql/test/emptydb/Tests/check.stable.out.32bit
        sql/test/emptydb/Tests/check.stable.out.int128
        sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.32bit
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade/Tests/upgrade.stable.out
        sql/test/testdb-upgrade/Tests/upgrade.stable.out.32bit
        sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: Jun2020
Log Message:

merged


diffs (truncated from 1029 to 300 lines):

diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -53,7 +53,7 @@ unshare_string_heap(BAT *b)
 #endif
 
 static gdk_return
-insert_string_bat(BAT *b, BAT *n, BAT *s, bool force)
+insert_string_bat(BAT *b, BAT *n, struct canditer *ci, bool force)
 {
        BATiter ni;             /* iterator */
        size_t toff = ~(size_t) 0;      /* tail offset */
@@ -66,20 +66,16 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
 #endif
        var_t v;                /* value */
        size_t off;             /* offset within n's string heap */
-       struct canditer ci;
-       BUN cnt;
+       BUN cnt = ci->ncand;
        BUN oldcnt = BATcount(b);
 
        assert(b->ttype == TYPE_str);
        /* only transient bats can use some other bat's string heap */
        assert(b->batRole == TRANSIENT || b->tvheap->parentid == b->batCacheid);
-       if (n->batCount == 0 || (s && s->batCount == 0))
+       if (cnt == 0)
                return GDK_SUCCEED;
        ni = bat_iterator(n);
        tp = NULL;
-       cnt = canditer_init(&ci, n, s);
-       if (cnt == 0)
-               return GDK_SUCCEED;
        if ((!GDK_ELIMDOUBLES(b->tvheap) || oldcnt == 0) &&
            !GDK_ELIMDOUBLES(n->tvheap) &&
            b->tvheap->hashash == n->tvheap->hashash) {
@@ -106,7 +102,7 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
                         * heap */
                        if (oldcnt == 0 &&
                            b->tvheap != n->tvheap &&
-                           ci.tpe == cand_dense) {
+                           ci->tpe == cand_dense) {
                                if (b->tvheap->parentid != bid) {
                                        BBPunshare(b->tvheap->parentid);
                                } else {
@@ -118,7 +114,7 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
                                b->batDirtydesc = true;
                                toff = 0;
                        } else if (b->tvheap->parentid == n->tvheap->parentid &&
-                                  ci.tpe == cand_dense) {
+                                  ci->tpe == cand_dense) {
                                toff = 0;
                        } else if (b->tvheap->parentid != bid &&
                                   unshare_string_heap(b) != GDK_SUCCEED) {
@@ -148,7 +144,7 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
                        size_t len = b->tvheap->hashash ? 1024 * EXTRALEN : 0;
                        for (i = 0; i < 1024; i++) {
                                p = (BUN) (((double) rand() / RAND_MAX) * (cnt 
- 1));
-                               p = canditer_idx(&ci, p) - n->hseqbase;
+                               p = canditer_idx(ci, p) - n->hseqbase;
                                off = BUNtvaroff(ni, p);
                                if (off < b->tvheap->free &&
                                    strcmp(b->tvheap->base + off, 
n->tvheap->base + off) == 0 &&
@@ -198,10 +194,10 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
                }
        } else if (unshare_string_heap(b) != GDK_SUCCEED)
                return GDK_FAIL;
-       if (toff == 0 && n->twidth == b->twidth && ci.tpe == cand_dense) {
+       if (toff == 0 && n->twidth == b->twidth && ci->tpe == cand_dense) {
                /* we don't need to do any translation of offset
                 * values, so we can use fast memcpy */
-               memcpy(Tloc(b, BUNlast(b)), Tloc(n, ci.seq - n->hseqbase), cnt 
<< n->tshift);
+               memcpy(Tloc(b, BUNlast(b)), Tloc(n, ci->seq - n->hseqbase), cnt 
<< n->tshift);
                BATsetcount(b, oldcnt + cnt);
        } else if (toff != ~(size_t) 0) {
                /* we don't need to insert any actual strings since we
@@ -251,7 +247,7 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
                b->tvarsized = false;
                while (cnt > 0) {
                        cnt--;
-                       p = canditer_next(&ci) - n->hseqbase;
+                       p = canditer_next(ci) - n->hseqbase;
                        switch (n->twidth) {
                        case 1:
                                v = (var_t) tbp[p] + GDK_VAROFFSET;
@@ -316,7 +312,7 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
                oid hseq = n->hseqbase;
                while (cnt > 0) {
                        cnt--;
-                       p = canditer_next(&ci) - hseq;
+                       p = canditer_next(ci) - hseq;
                        tp = BUNtvar(ni, p);
                        if (bunfastappVAR(b, tp) != GDK_SUCCEED)
                                goto bunins_failed;
@@ -332,7 +328,7 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
                r = BUNlast(b);
                while (cnt > 0) {
                        cnt--;
-                       p = canditer_next(&ci) - n->hseqbase;
+                       p = canditer_next(ci) - n->hseqbase;
                        off = BUNtvaroff(ni, p); /* the offset */
                        tp = n->tvheap->base + off; /* the string */
                        if (off < b->tvheap->free &&
@@ -397,11 +393,10 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
 }
 
 static gdk_return
-append_varsized_bat(BAT *b, BAT *n, BAT *s)
+append_varsized_bat(BAT *b, BAT *n, struct canditer *ci)
 {
        BATiter ni;
-       struct canditer ci;
-       BUN cnt, r;
+       BUN cnt = ci->ncand, r;
        oid hseq = n->hseqbase;
 
        /* only transient bats can use some other bat's vheap */
@@ -409,9 +404,6 @@ append_varsized_bat(BAT *b, BAT *n, BAT 
        /* make sure the bats use var_t */
        assert(b->twidth == n->twidth);
        assert(b->twidth == SIZEOF_VAR_T);
-       if (n->batCount == 0 || (s && s->batCount == 0))
-               return GDK_SUCCEED;
-       cnt = canditer_init(&ci, n, s);
        if (cnt == 0)
                return GDK_SUCCEED;
        if (BATcount(b) == 0 &&
@@ -434,24 +426,24 @@ append_varsized_bat(BAT *b, BAT *n, BAT 
        if (b->tvheap == n->tvheap) {
                /* if b and n use the same vheap, we only need to copy
                 * the offsets from n to b */
-               if (ci.tpe == cand_dense) {
+               if (ci->tpe == cand_dense) {
                        /* fast memcpy since we copy a consecutive
                         * chunk of memory */
                        memcpy(Tloc(b, BUNlast(b)),
-                              Tloc(n, ci.seq - hseq),
+                              Tloc(n, ci->seq - hseq),
                               cnt << b->tshift);
                } else {
                        var_t *restrict dst = (var_t *) Tloc(b, BUNlast(b));
                        const var_t *restrict src = (const var_t *) Tloc(n, 0);
                        while (cnt > 0) {
                                cnt--;
-                               *dst++ = src[canditer_next(&ci) - hseq];
+                               *dst++ = src[canditer_next(ci) - hseq];
                        }
                }
                b->theap.dirty = true;
-               BATsetcount(b, BATcount(b) + ci.ncand);
+               BATsetcount(b, BATcount(b) + ci->ncand);
                /* maintain hash table */
-               for (BUN i = BATcount(b) - ci.ncand;
+               for (BUN i = BATcount(b) - ci->ncand;
                     b->thash && i < BATcount(b);
                     i++) {
                        HASHins(b, i, b->tvheap->base + ((var_t *) 
b->theap.base)[i]);
@@ -481,7 +473,7 @@ append_varsized_bat(BAT *b, BAT *n, BAT 
        r = BUNlast(b);
        while (cnt > 0) {
                cnt--;
-               BUN p = canditer_next(&ci) - hseq;
+               BUN p = canditer_next(ci) - hseq;
                const void *t = BUNtvar(ni, p);
                if (bunfastapp_nocheckVAR(b, r, t, Tsize(b)) != GDK_SUCCEED)
                        return GDK_FAIL;
@@ -676,11 +668,11 @@ BATappend(BAT *b, BAT *n, BAT *s, bool f
                b->tnil |= n->tnil && cnt == BATcount(n);
        }
        if (b->ttype == TYPE_str) {
-               if (insert_string_bat(b, n, s, force) != GDK_SUCCEED) {
+               if (insert_string_bat(b, n, &ci, force) != GDK_SUCCEED) {
                        return GDK_FAIL;
                }
        } else if (ATOMvarsized(b->ttype)) {
-               if (append_varsized_bat(b, n, s) != GDK_SUCCEED) {
+               if (append_varsized_bat(b, n, &ci) != GDK_SUCCEED) {
                        return GDK_FAIL;
                }
        } else {
diff --git a/monetdb5/mal/mal_import.c b/monetdb5/mal/mal_import.c
--- a/monetdb5/mal/mal_import.c
+++ b/monetdb5/mal/mal_import.c
@@ -259,6 +259,7 @@ evalFile(str fname, int listing)
        stream *fd;
        str filename;
        str msg = MAL_SUCCEED;
+       bstream *bs;
 
        filename = malResolveFile(fname);
        if (filename == NULL)
@@ -270,8 +271,12 @@ evalFile(str fname, int listing)
                        close_stream(fd);
                throw(MAL,"mal.eval", "WARNING: could not open file '%s'\n", 
fname);
        }
-
-       c= MCinitClient(MAL_ADMIN, bstream_create(fd, 128 * BLOCK),0);
+       if (!(bs = bstream_create(fd, 128 * BLOCK))) {
+               if (fd)
+                       close_stream(fd);
+               throw(MAL,"mal.eval",SQLSTATE(HY013) MAL_MALLOC_FAIL);
+       }
+       c= MCinitClient(MAL_ADMIN, bs, 0);
        if( c == NULL){
                throw(MAL,"mal.eval","Can not create user context");
        }
diff --git a/sql/ChangeLog.Jun2020 b/sql/ChangeLog.Jun2020
--- a/sql/ChangeLog.Jun2020
+++ b/sql/ChangeLog.Jun2020
@@ -1,6 +1,10 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Thu Apr 23 2020 Pedro Ferreira <pedro.ferre...@monetdbsolutions.com>
+- Updating the value of a sequence now requires privilege on its own
+  schema.
+
 * Thu Apr 16 2020 Sjoerd Mullender <sjo...@acm.org>
 - The sys.querylog_enable(threshold integer) now actually enables the
   querylog and uses a threshold in milliseconds.
@@ -35,11 +39,6 @@
   implementation, the backend code generation, creates two additional
   columns of lng type with the start and end offsets for each row.
 
-* Thu Jan 23 2020 Pedro Ferreira <pedro.ferre...@monetdbsolutions.com>
-- Added sys.sleep(int n) procedure, which makes the client's thread to
-  sleep for n milliseconds. Also added the function version, where it
-  returns the input value as result.
-
 * Tue Dec 17 2019 Pedro Ferreira <pedro.ferre...@monetdbsolutions.com>
 - Added prepared_statements_args view, which details the arguments for
   the prepared statements created in the current session.
@@ -79,7 +78,7 @@
   The versions of the mentioned procedures with just the second argument were
   added as well, where the changes are reflected in the current user session,
   and therefore every user can call them.
-- The procedures sys.settimeout(bigint), sys.settimeout(bigint,bigint) 
+- The procedures sys.settimeout(bigint), sys.settimeout(bigint,bigint)
   and sys.session(bigint) are now deprecated. Instead use sys.setquerytimeout
   and sys.setsessiontimeout mentioned above.
 
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -3354,8 +3354,15 @@ mvc_bin_import_table_wrap(Client cntxt, 
                                        goto bailout;
                                }
                                bstream *s = bstream_create(ss, 1 << 20);
-
-                               c = 
BATattach_bstream(col->type.type->localtype, s, be->mvc->scanner.ws, cnt);
+                               if (!s) {
+                                       msg = createException(SQL, "sql", 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+                                       goto bailout;
+                               }
+                               if (!(c = 
BATattach_bstream(col->type.type->localtype, s, be->mvc->scanner.ws, cnt))) {
+                                       bstream_destroy(s);
+                                       msg = createException(SQL, "sql", 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+                                       goto bailout;
+                               }
                                mnstr_write(be->mvc->scanner.ws, PROMPT3, 
sizeof(PROMPT3)-1, 1);
                                mnstr_flush(be->mvc->scanner.ws);
                                be->mvc->scanner.rs->eof = s->eof;
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
@@ -2470,25 +2470,7 @@ sql_update_jun2020(Client c, mvc *sql, c
                        " external name mdb.\"setDebug\";\n"
                        "create function sys.debugflags()\n"
                        " returns table(flag string, val bool)\n"
-                       " external name mdb.\"getDebugFlags\";\n"
-                       "create procedure sys.\"sleep\"(msecs tinyint)\n"
-                       " external name \"alarm\".\"sleep\";\n"
-                       "grant execute on procedure sys.\"sleep\"(tinyint) to 
public;\n"
-                       "create procedure sys.\"sleep\"(msecs smallint)\n"
-                       " external name \"alarm\".\"sleep\";\n"
-                       "grant execute on procedure sys.\"sleep\"(smallint) to 
public;\n"
-                       "create procedure sys.\"sleep\"(msecs int)\n"
-                       " external name \"alarm\".\"sleep\";\n"
-                       " grant execute on procedure sys.\"sleep\"(int) to 
public;\n"
-                       "create function sys.\"sleep\"(msecs tinyint) returns 
tinyint\n"
-                       " external name \"alarm\".\"sleep\";\n"
-                       "grant execute on function sys.\"sleep\"(tinyint) to 
public;\n"
-                       "create function sys.\"sleep\"(msecs smallint) returns 
smallint\n"
-                       " external name \"alarm\".\"sleep\";\n"
-                       "grant execute on function sys.\"sleep\"(smallint) to 
public;\n"
-                       "create function sys.\"sleep\"(msecs int) returns int\n"
-                       " external name \"alarm\".\"sleep\";\n"
-                       " grant execute on function sys.\"sleep\"(int) to 
public;\n");
+                       " external name mdb.\"getDebugFlags\";\n");
        pos += snprintf(buf + pos, bufsize - pos,
                        "update sys.functions set system = true where schema_id 
= (select id from sys.schemas where name = 'sys')"
                        " and name in ('debug', 'debugflags', 'sleep');\n");
diff --git a/sql/scripts/25_debug.sql b/sql/scripts/25_debug.sql
--- a/sql/scripts/25_debug.sql
+++ b/sql/scripts/25_debug.sql
@@ -81,25 +81,3 @@ create function sys.deltas ("schema" str
 create function sys.deltas ("schema" string, "table" string, "column" string)
        returns table ("id" int, "cleared" boolean, "immutable" bigint, 
"inserted" bigint, "updates" bigint, "deletes" bigint, "level" int)
        external name "sql"."deltas";
-
--- Sleep procedure
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to