Changeset: 475f3f8df7b1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/475f3f8df7b1
Modified Files:
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql.c
        sql/storage/bat/bat_storage.c
Branch: directappend
Log Message:

merged with default


diffs (truncated from 1977 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -6042,6 +6042,7 @@
 [ "batmmath",  "radians",      "pattern batmmath.radians(X_0:bat[:flt], 
X_1:bat[:oid]):bat[:flt] ",    "CMDscience_bat_radians;",      ""      ]
 [ "batmmath",  "rand", "unsafe pattern batmmath.rand(X_0:bat[:int]):bat[:int] 
",       "CMDscience_bat_randintarg;",   ""      ]
 [ "batmmath",  "rand", "unsafe pattern batmmath.rand(X_0:bat[:int], 
X_1:bat[:oid]):bat[:int] ",        "CMDscience_bat_randintarg;",   ""      ]
+[ "batmmath",  "rand", "unsafe pattern batmmath.rand(X_0:lng):bat[:int] ",     
"CMDscience_bat_randintarg;",   ""      ]
 [ "batmmath",  "sin",  "pattern batmmath.sin(X_0:bat[:dbl]):bat[:dbl] ",       
"CMDscience_bat_sin;",  ""      ]
 [ "batmmath",  "sin",  "pattern batmmath.sin(X_0:bat[:dbl], 
X_1:bat[:oid]):bat[:dbl] ",        "CMDscience_bat_sin;",  ""      ]
 [ "batmmath",  "sin",  "pattern batmmath.sin(X_0:bat[:flt]):bat[:flt] ",       
"CMDscience_bat_sin;",  ""      ]
@@ -6607,7 +6608,8 @@
 [ "batstr",    "unicodeAt",    "pattern batstr.unicodeAt(X_0:bat[:str], 
X_1:int, X_2:bat[:oid]):bat[:int] ",   "STRbatWChrAtcst;",     "get a unicode 
character (as an int) from a string position."   ]
 [ "battxtsim", "similarity",   "command battxtsim.similarity(X_0:bat[:str], 
X_1:bat[:str]):bat[:dbl] ",        "fstrcmp0_impl_bulk;",  "Normalized edit 
distance between two strings"  ]
 [ "batuuid",   "isaUUID",      "command 
batuuid.isaUUID(X_0:bat[:str]):bat[:bit] ",    "UUIDisaUUID_bulk;",    "Test a 
string for a UUID format"       ]
-[ "batuuid",   "new",  "command batuuid.new(X_0:bat[:int]):bat[:uuid] ",       
"UUIDgenerateUuidInt_bulk;",    "Generate a new uuid (dummy version for side 
effect free multiplex loop)"       ]
+[ "batuuid",   "new",  "pattern batuuid.new(X_0:bat[:int]):bat[:uuid] ",       
"UUIDgenerateUuidInt_bulk;",    "Generate a new uuid (dummy version for side 
effect free multiplex loop)"       ]
+[ "batuuid",   "new",  "pattern batuuid.new(X_0:lng):bat[:uuid] ",     
"UUIDgenerateUuidInt_bulk;",    "Generate a new uuid (dummy version for side 
effect free multiplex loop)"       ]
 [ "batxml",    "attribute",    "command batxml.attribute(X_0:str, 
X_1:bat[:str]):bat[:xml] ",  "BATXMLattribute;",     "Construct an attribute 
value pair."    ]
 [ "batxml",    "comment",      "command 
batxml.comment(X_0:bat[:str]):bat[:xml] ",     "BATXMLcomment;",       "Create 
an XML comment element."        ]
 [ "batxml",    "concat",       "command batxml.concat(X_0:bat[:xml], 
X_1:bat[:xml]):bat[:xml] ",       "BATXMLconcat;",        "Concatenate the XML 
values."   ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -8572,6 +8572,7 @@
 [ "batmmath",  "radians",      "pattern batmmath.radians(X_0:bat[:flt], 
X_1:bat[:oid]):bat[:flt] ",    "CMDscience_bat_radians;",      ""      ]
 [ "batmmath",  "rand", "unsafe pattern batmmath.rand(X_0:bat[:int]):bat[:int] 
",       "CMDscience_bat_randintarg;",   ""      ]
 [ "batmmath",  "rand", "unsafe pattern batmmath.rand(X_0:bat[:int], 
X_1:bat[:oid]):bat[:int] ",        "CMDscience_bat_randintarg;",   ""      ]
+[ "batmmath",  "rand", "unsafe pattern batmmath.rand(X_0:lng):bat[:int] ",     
"CMDscience_bat_randintarg;",   ""      ]
 [ "batmmath",  "sin",  "pattern batmmath.sin(X_0:bat[:dbl]):bat[:dbl] ",       
"CMDscience_bat_sin;",  ""      ]
 [ "batmmath",  "sin",  "pattern batmmath.sin(X_0:bat[:dbl], 
X_1:bat[:oid]):bat[:dbl] ",        "CMDscience_bat_sin;",  ""      ]
 [ "batmmath",  "sin",  "pattern batmmath.sin(X_0:bat[:flt]):bat[:flt] ",       
"CMDscience_bat_sin;",  ""      ]
@@ -9166,7 +9167,8 @@
 [ "batstr",    "unicodeAt",    "pattern batstr.unicodeAt(X_0:bat[:str], 
X_1:int, X_2:bat[:oid]):bat[:int] ",   "STRbatWChrAtcst;",     "get a unicode 
character (as an int) from a string position."   ]
 [ "battxtsim", "similarity",   "command battxtsim.similarity(X_0:bat[:str], 
X_1:bat[:str]):bat[:dbl] ",        "fstrcmp0_impl_bulk;",  "Normalized edit 
distance between two strings"  ]
 [ "batuuid",   "isaUUID",      "command 
batuuid.isaUUID(X_0:bat[:str]):bat[:bit] ",    "UUIDisaUUID_bulk;",    "Test a 
string for a UUID format"       ]
-[ "batuuid",   "new",  "command batuuid.new(X_0:bat[:int]):bat[:uuid] ",       
"UUIDgenerateUuidInt_bulk;",    "Generate a new uuid (dummy version for side 
effect free multiplex loop)"       ]
+[ "batuuid",   "new",  "pattern batuuid.new(X_0:bat[:int]):bat[:uuid] ",       
"UUIDgenerateUuidInt_bulk;",    "Generate a new uuid (dummy version for side 
effect free multiplex loop)"       ]
+[ "batuuid",   "new",  "pattern batuuid.new(X_0:lng):bat[:uuid] ",     
"UUIDgenerateUuidInt_bulk;",    "Generate a new uuid (dummy version for side 
effect free multiplex loop)"       ]
 [ "batxml",    "attribute",    "command batxml.attribute(X_0:str, 
X_1:bat[:str]):bat[:xml] ",  "BATXMLattribute;",     "Construct an attribute 
value pair."    ]
 [ "batxml",    "comment",      "command 
batxml.comment(X_0:bat[:str]):bat[:xml] ",     "BATXMLcomment;",       "Create 
an XML comment element."        ]
 [ "batxml",    "concat",       "command batxml.concat(X_0:bat[:xml], 
X_1:bat[:xml]):bat[:xml] ",       "BATXMLconcat;",        "Concatenate the XML 
values."   ]
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -3326,9 +3326,10 @@ BATgroupsize(BAT *b, BAT *g, BAT *e, BAT
                                i = canditer_next(ci) - hseq;           \
                                if (!skip_nils ||                       \
                                    !is_##TYPE##_nil(vals[i])) {        \
-                                       oids[gid++] = i + hseq;         \
+                                       oids[gid] = i + hseq;           \
                                        nils--;                         \
                                }                                       \
+                               gid++;                                  \
                        }                                               \
                        TIMEOUT_CHECK(timeoffset,                       \
                                      TIMEOUT_HANDLER(BUN_NONE));       \
@@ -3447,9 +3448,10 @@ do_groupmin(oid *restrict oids, BATiter 
                                i = canditer_next(ci) - hseq;
                                if (!skip_nils ||
                                    (*atomcmp)(BUNtail(*bi, i), nil) != 0) {
-                                       oids[gid++] = i + hseq;
+                                       oids[gid] = i + hseq;
                                        nils--;
                                }
+                               gid++;
                        }
                        TIMEOUT_CHECK(timeoffset,
                                      TIMEOUT_HANDLER(BUN_NONE));
@@ -3576,9 +3578,10 @@ do_groupmax(oid *restrict oids, BATiter 
                                i = canditer_next(ci) - hseq;
                                if (!skip_nils ||
                                    (*atomcmp)(BUNtail(*bi, i), nil) != 0) {
-                                       oids[gid++] = i + hseq;
+                                       oids[gid] = i + hseq;
                                        nils--;
                                }
+                               gid++;
                        }
                        TIMEOUT_CHECK(timeoffset,
                                      TIMEOUT_HANDLER(BUN_NONE));
diff --git a/monetdb5/modules/atoms/uuid.c b/monetdb5/modules/atoms/uuid.c
--- a/monetdb5/modules/atoms/uuid.c
+++ b/monetdb5/modules/atoms/uuid.c
@@ -19,7 +19,7 @@
 #endif
 #include "mal.h"
 #include "mal_exception.h"
-#include "mal_atom.h"                  /* for malAtomSize */
+#include "mal_interpreter.h"
 
 #if !defined(HAVE_UUID) && !defined(HAVE_GETENTROPY) && defined(HAVE_RAND_S)
 static inline bool
@@ -109,19 +109,27 @@ isaUUID(const char *s)
 }
 
 static str
-UUIDgenerateUuidInt_bulk(bat *ret, const bat *bid)
+UUIDgenerateUuidInt_bulk(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci)
 {
        BAT *b = NULL, *bn = NULL;
        BUN n = 0;
        str msg = MAL_SUCCEED;
        uuid *restrict bnt = NULL;
+       bat *ret = getArgReference_bat(stk, pci, 0);
 
-       if ((b = BBPquickdesc(*bid)) == NULL)   {
-               msg = createException(MAL, "uuid.generateuuidint_bulk", 
SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
-               goto bailout;
+       (void) cntxt;
+       if (isaBatType(getArgType(mb, pci, 1))) {
+               bat *bid = getArgReference_bat(stk, pci, 1);
+               if (!(b = BBPquickdesc(*bid))) {
+                       msg = createException(MAL, "uuid.generateuuidint_bulk", 
SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
+                       goto bailout;
+               }
+               n = BATcount(b);
+       } else {
+               n = (BUN) *getArgReference_lng(stk, pci, 1);
        }
-       n = BATcount(b);
-       if ((bn = COLnew(b->hseqbase, TYPE_uuid, n, TRANSIENT)) == NULL) {
+
+       if ((bn = COLnew(b ? b->hseqbase : 0, TYPE_uuid, n, TRANSIENT)) == 
NULL) {
                msg = createException(MAL, "uuid.generateuuidint_bulk", 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
                goto bailout;
        }
@@ -454,7 +462,8 @@ bailout:
 mel_func uuid_init_funcs[] = {
  command("uuid", "new", UUIDgenerateUuid, true, "Generate a new uuid", 
args(1,1, arg("",uuid))),
  command("uuid", "new", UUIDgenerateUuidInt, false, "Generate a new uuid 
(dummy version for side effect free multiplex loop)", args(1,2, 
arg("",uuid),arg("d",int))),
- command("batuuid", "new", UUIDgenerateUuidInt_bulk, false, "Generate a new 
uuid (dummy version for side effect free multiplex loop)", args(1,2, 
batarg("",uuid),batarg("d",int))),
+ pattern("batuuid", "new", UUIDgenerateUuidInt_bulk, false, "Generate a new 
uuid (dummy version for side effect free multiplex loop)", args(1,2, 
batarg("",uuid),batarg("d",int))),
+ pattern("batuuid", "new", UUIDgenerateUuidInt_bulk, false, "Generate a new 
uuid (dummy version for side effect free multiplex loop)", args(1,2, 
batarg("",uuid),arg("card",lng))), /* version with cardinality input */
  command("uuid", "uuid", UUIDstr2uuid, false, "Coerce a string to a uuid, 
validating its format", args(1,2, arg("",uuid),arg("s",str))),
  command("uuid", "str", UUIDuuid2str, false, "Coerce a uuid to its string 
type", args(1,2, arg("",str),arg("u",uuid))),
  command("uuid", "isaUUID", UUIDisaUUID, false, "Test a string for a UUID 
format", args(1,2, arg("",bit),arg("u",str))),
diff --git a/monetdb5/modules/kernel/batmmath.c 
b/monetdb5/modules/kernel/batmmath.c
--- a/monetdb5/modules/kernel/batmmath.c
+++ b/monetdb5/modules/kernel/batmmath.c
@@ -385,20 +385,26 @@ CMDscience_bat_randintarg(Client cntxt, 
        int *restrict vals;
        str msg = MAL_SUCCEED;
        struct canditer ci = {0};
-       bat *res = getArgReference_bat(stk, pci, 0), *bid = 
getArgReference_bat(stk, pci, 1),
-               *sid = pci->argc == 3 ? getArgReference_bat(stk, pci, 2) : NULL;
+       bat *res = getArgReference_bat(stk, pci, 0);
 
        (void) cntxt;
-       (void) mb;
-       if (!(b = BBPquickdesc(*bid))) {
-               msg = createException(MAL, "batmmath.rand", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
-               goto bailout;
+       if (isaBatType(getArgType(mb, pci, 1))) {
+               bat *bid = getArgReference_bat(stk, pci, 1), *sid = pci->argc 
== 3 ? getArgReference_bat(stk, pci, 2) : NULL;
+               if (!(b = BBPquickdesc(*bid))) {
+                       msg = createException(MAL, "batmmath.rand", 
SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
+                       goto bailout;
+               }
+               if (sid && !is_bat_nil(*sid) && !(bs = BATdescriptor(*sid))) {
+                       msg = createException(MAL, "batmmath.rand", 
SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
+                       goto bailout;
+               }
+               q = canditer_init(&ci, b, bs);
+               if (bs)
+                       BBPunfix(bs->batCacheid);
+       } else {
+               q = (BUN) *getArgReference_lng(stk, pci, 1);
        }
-       if (sid && !is_bat_nil(*sid) && !(bs = BATdescriptor(*sid))) {
-               msg = createException(MAL, "batmmath.rand", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
-               goto bailout;
-       }
-       q = canditer_init(&ci, b, bs);
+
        if (!(bn = COLnew(ci.hseq, TYPE_int, q, TRANSIENT))) {
                msg = createException(MAL, "batmmath.rand", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
                goto bailout;
@@ -416,8 +422,6 @@ CMDscience_bat_randintarg(Client cntxt, 
 #endif
 
 bailout:
-       if (bs)
-               BBPunfix(bs->batCacheid);
        if (bn && !msg) {
                BATsetcount(bn, q);
                bn->tnil = false;
@@ -581,6 +585,7 @@ mel_func batmmath_init_funcs[] = {
  pattern("batmmath", "pow", CMDscience_bat_pow, false, "", args(1,4, 
batarg("",flt),arg("x",flt),batarg("y",flt),batarg("s",oid))),
  pattern("batmmath", "rand", CMDscience_bat_randintarg, true, "", args(1,2, 
batarg("",int),batarg("v",int))),
  pattern("batmmath", "rand", CMDscience_bat_randintarg, true, "", args(1,3, 
batarg("",int),batarg("v",int),batarg("s",oid))),
+ pattern("batmmath", "rand", CMDscience_bat_randintarg, true, "", args(1,2, 
batarg("",int),arg("card",lng))), /* version with cardinality input */
  { .imp=NULL }
 };
 #include "mal_import.h"
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -2276,7 +2276,7 @@ rel2bin_hash_lookup(backend *be, sql_rel
                        sql_subfunc *xor = sql_bind_func_result(sql, "sys", 
"rotate_xor_hash", F_FUNC, lng, 3, lng, it, tail_type(s));
 
                        h = stmt_Nop(be, stmt_list(be, list_append( list_append(
-                               list_append(sa_list(sql->sa), h), bits), s)), 
NULL, xor, false);
+                               list_append(sa_list(sql->sa), h), bits), s)), 
NULL, xor, NULL);
                        semantics = 1;
                } else {
                        sql_subfunc *hf = sql_bind_func_result(sql, "sys", 
"hash", F_FUNC, lng, 1, tail_type(s));
@@ -2324,7 +2324,6 @@ join_hash_key( backend *be, list *l )
 static stmt *
 releqjoin( backend *be, list *l1, list *l2, list *exps, int used_hash, int 
need_left, int is_semantics )
 {
-       mvc *sql = be->mvc;
        node *n1 = l1->h, *n2 = l2->h, *n3 = NULL;
        stmt *l, *r, *res;
        sql_exp *e;
@@ -2361,25 +2360,14 @@ releqjoin( backend *be, list *l1, list *
                stmt *rd = n2->data;
                stmt *le = stmt_project(be, l, ld );
                stmt *re = stmt_project(be, r, rd );
+               stmt *cmp;
                /* intentional both tail_type's of le (as re sometimes is a 
find for bulk loading */
-               sql_subfunc *f = NULL;
-               stmt * cmp;
-               list *ops;
-
-               f = sql_bind_func(sql, "sys", "=", tail_type(le), 
tail_type(le), F_FUNC);
-               assert(f);
-
-               ops = sa_list(be->mvc->sa);
-               list_append(ops, le);
-               list_append(ops, re);
+
                if (!semantics && exps) {
                        e = n3->data;
                        semantics = is_semantics(e);
                }
-               if (semantics)
-                       list_append(ops, stmt_bool(be, 1));
-               cmp = stmt_Nop(be, stmt_list(be, ops), NULL, f, NULL);
-               cmp = stmt_uselect(be, cmp, stmt_bool(be, 1), cmp_equal, NULL, 
0, 0);
+               cmp = stmt_uselect(be, le, re, cmp_equal, NULL, 0, semantics);
                l = stmt_project(be, cmp, l );
                r = stmt_project(be, cmp, r );
        }
@@ -2537,7 +2525,7 @@ rel2bin_join(backend *be, sql_rel *rel, 
                        (void) equality_only;
                        jexps = get_equi_joins_first(sql, jexps, 
&equality_only);
                        /* generate a relational join (releqjoin) which does a 
multi attribute (equi) join */
-                       for( en = jexps->h; en && !used_hash; en = en->next ) {
+                       for( en = jexps->h; en ; en = en->next ) {
                                int join_idx = be->join_idx;
                                sql_exp *e = en->data;
                                stmt *s = NULL;
@@ -2557,15 +2545,14 @@ rel2bin_join(backend *be, sql_rel *rel, 
                                                list_append(lje, s->op1);
                                                list_append(rje, s->op2);
                                                list_append(exps, NULL);
-                                               used_hash = 1; /* uses hash, 
all jexps were consumed */
+                                               used_hash = 1;
                                        } else {
                                                /* hash lookup cannot be used, 
clean leftover mal statements */
                                                clean_mal_statements(be, 
oldstop, oldvtop, oldvid);
                                        }
                                }
 
-                               if (!s)
-                                       s = exp_bin(be, e, left, right, NULL, 
NULL, NULL, NULL, 0, 1, 0);
+                               s = exp_bin(be, e, left, right, NULL, NULL, 
NULL, NULL, 0, 1, 0);
                                if (!s) {
                                        assert(sql->session->status == -10); /* 
Stack overflow errors shouldn't terminate the server */
                                        return NULL;
@@ -3635,10 +3622,10 @@ rel2bin_select(backend *be, sql_rel *rel
                        sql_idx *i = p->value;
                        int oldvtop = be->mb->vtop, oldstop = be->mb->stop, 
oldvid = be->mb->vid;
 
-                       if ((sel = rel2bin_hash_lookup(be, rel, sub, NULL, i, 
en)))
-                               goto done;
-                       /* hash lookup cannot be used, clean leftover mal 
statements */
-                       clean_mal_statements(be, oldstop, oldvtop, oldvid);
+                       if (!(sel = rel2bin_hash_lookup(be, rel, sub, NULL, i, 
en))) {
+                               /* hash lookup cannot be used, clean leftover 
mal statements */
+                               clean_mal_statements(be, oldstop, oldvtop, 
oldvid);
+                       }
                }
        }
        for( en = rel->exps->h; en; en = en->next ) {
@@ -3665,7 +3652,6 @@ rel2bin_select(backend *be, sql_rel *rel
                }
        }
 
-done:
        if (sub && sel) {
                sub = stmt_list(be, sub->op4.lval); /* protect against 
references */
                sub->cand = sel;
@@ -5202,7 +5188,7 @@ hash_update(backend *be, sql_idx * i, st
                        h = stmt_Nop(be, stmt_list( be, list_append( 
list_append(
                                list_append(sa_list(sql->sa), h),
                                stmt_atom_int(be, bits)),  upd)), NULL,
-                               xor, false);
+                               xor, NULL);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to