Changeset: 95af8672c992 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/95af8672c992
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        sql/backends/monet5/sql.c
Branch: string_imprints
Log Message:

Merge with default


diffs (truncated from 599 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/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 );
        }
@@ -4951,7 +4939,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);
                } else if (h)  {
                        stmt *h2;
                        sql_subfunc *lsh = sql_bind_func_result(sql, "sys", 
"left_shift", F_FUNC, lng, 2, lng, it);
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
@@ -957,13 +957,14 @@ mvc_next_value_bulk(Client cntxt, MalBlk
                be->last_id = end;
                sqlvar_set_number(find_global_var(be->mvc, 
mvc_bind_schema(be->mvc, "sys"), "last_id"), be->last_id);
                lng c = start;
-               for(BUN i = 0; i<card; i++) {
-                       if (c > maxv && minv && maxv)
+               for(BUN i = 0; i<card; ) {
+                       if (maxv && c > maxv) {
+                               if (!seq->cycle)
+                                       break;
                                c = minv;
-                       if (c > maxv && !minv)
-                               break;
-                       rb[i] = c;
-                       if ((i+1) < card)
+                       }
+                       rb[i++] = c;
+                       if (i < card)
                                c += inc;
                }
                assert(c == end);
diff --git a/sql/backends/monet5/sql_statement.c 
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -40,14 +40,6 @@ convertMultiplexFcn(const char *op)
        return op;
 }
 
-static const char *
-convertOperator(const char *op)
-{
-       if (strcmp(op, "=") == 0)
-               return "==";
-       return op;
-}
-
 static InstrPtr
 multiplex2(MalBlkPtr mb, const char *mod, const char *name, int o1, int o2, 
int rtype)
 {
@@ -1369,7 +1361,7 @@ stmt_genselect(backend *be, stmt *lops, 
                node *n;
 
                op = sa_strconcat(be->mvc->sa, op, selectRef);
-               q = newStmtArgs(mb, mod, convertOperator(op), 9);
+               q = newStmtArgs(mb, mod, convertMultiplexFcn(op), 9);
                // push pointer to the SQL structure into the MAL call
                // allows getting argument names for example
                if (LANG_EXT(f->func->lang))
@@ -1472,7 +1464,7 @@ stmt_uselect(backend *be, stmt *op1, stm
                        TRC_ERROR(SQL_EXECUTION, "Unknown operator\n");
                }
 
-               if ((q = multiplex2(mb, mod, convertOperator(op), l, r, 
TYPE_bit)) == NULL)
+               if ((q = multiplex2(mb, mod, convertMultiplexFcn(op), l, r, 
TYPE_bit)) == NULL)
                        return NULL;
                if (sub && (op1->cand || op2->cand)) {
                        if (op1->cand && !op2->cand) {
@@ -3312,16 +3304,16 @@ stmt_Nop(backend *be, stmt *ops, stmt *s
        InstrPtr q = NULL;
        const char *mod = sql_func_mod(f->func), *fimp = sql_func_imp(f->func);
        sql_subtype *tpe = NULL;
-       int push_cands = 0;
-
-       node *n;
-       stmt *o = NULL;
+       int push_cands = 0, default_nargs;
+       stmt *o = NULL, *card = NULL;
 
        if (rows) {
+               if (sel) /* if there's a candidate list, use it instead of 
'rows' */
+                       rows = sel;
                o = rows;
-       }
-       else if (list_length(ops->op4.lval)) {
-               for (n = ops->op4.lval->h, o = n->data; n; n = n->next) {
+       } else if (list_length(ops->op4.lval)) {
+               o = ops->op4.lval->h->data;
+               for (node *n = ops->op4.lval->h; n; n = n->next) {
                        stmt *c = n->data;
 
                        if (c && o->nrcols < c->nrcols)
@@ -3358,40 +3350,38 @@ stmt_Nop(backend *be, stmt *ops, stmt *s
                if (backend_create_subfunc(be, f, ops->op4.lval) < 0)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to