Changeset: 20e9278a137e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/20e9278a137e
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
monetdb5/modules/atoms/uuid.c
monetdb5/modules/kernel/batmmath.c
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql.c
Branch: pushcands
Log Message:
Merged with default
diffs (truncated from 375 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
@@ -4900,6 +4900,7 @@ stdout of test 'MAL-signatures` in direc
[ "batmmath", "radians", "pattern batmmath.radians(X_0:bat[:dbl],
X_1:bat[:oid]):bat[:dbl] ", "CMDscience_bat_radians;", "" ]
[ "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[:any],
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],
X_1:bat[:oid]):bat[:dbl] ", "CMDscience_bat_sin;", "" ]
[ "batmmath", "sin", "pattern batmmath.sin(X_0:bat[:flt],
X_1:bat[:oid]):bat[:flt] ", "CMDscience_bat_sin;", "" ]
[ "batmmath", "sinh", "pattern batmmath.sinh(X_0:bat[:dbl],
X_1:bat[:oid]):bat[:dbl] ", "CMDscience_bat_sinh;", "" ]
@@ -5294,7 +5295,8 @@ stdout of test 'MAL-signatures` in direc
[ "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[:any]):bat[:uuid] ",
"UUIDgenerateUuidInt_bulk;", "Generate a new uuid (dummy version for side
effect free multiplex loop)" ]
+[ "batuuid", "new", "pattern batuuid.new(X_0:bat[:any]):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
@@ -7028,6 +7028,7 @@ stdout of test 'MAL-signatures` in direc
[ "batmmath", "radians", "pattern batmmath.radians(X_0:bat[:dbl],
X_1:bat[:oid]):bat[:dbl] ", "CMDscience_bat_radians;", "" ]
[ "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[:any],
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],
X_1:bat[:oid]):bat[:dbl] ", "CMDscience_bat_sin;", "" ]
[ "batmmath", "sin", "pattern batmmath.sin(X_0:bat[:flt],
X_1:bat[:oid]):bat[:flt] ", "CMDscience_bat_sin;", "" ]
[ "batmmath", "sinh", "pattern batmmath.sinh(X_0:bat[:dbl],
X_1:bat[:oid]):bat[:dbl] ", "CMDscience_bat_sinh;", "" ]
@@ -7451,7 +7452,8 @@ stdout of test 'MAL-signatures` in direc
[ "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[:any]):bat[:uuid] ",
"UUIDgenerateUuidInt_bulk;", "Generate a new uuid (dummy version for side
effect free multiplex loop)" ]
+[ "batuuid", "new", "pattern batuuid.new(X_0:bat[:any]):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),argany("d",0))),
- command("batuuid", "new", UUIDgenerateUuidInt_bulk, false, "Generate a new
uuid (dummy version for side effect free multiplex loop)", args(1,2,
batarg("",uuid),batargany("d",0))),
+ pattern("batuuid", "new", UUIDgenerateUuidInt_bulk, false, "Generate a new
uuid (dummy version for side effect free multiplex loop)", args(1,2,
batarg("",uuid),batargany("d",0))),
+ 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;
@@ -520,6 +524,7 @@ mel_func batmmath_init_funcs[] = {
pattern("batmmath", "pow", CMDscience_bat_pow, false, "", args(1,4,
batarg("",dbl),arg("x",dbl),batarg("y",dbl),batarg("s",oid))),
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,3,
batarg("",int),batargany("v",0),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
@@ -2605,7 +2605,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;
@@ -2625,15 +2625,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, 0, 1,
0);
+ s = exp_bin(be, e, left, right, 0, 1, 0);
if (!s) {
assert(sql->session->status == -10); /*
Stack overflow errors shouldn't terminate the server */
return NULL;
@@ -3669,10 +3668,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)))
- return create_rel_bin_stmt(sql->sa, rel,
sub->cols, sel);
- /* 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);
+ }
}
}
if (sub && !sel)
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,15 +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++) {
+ for(BUN i = 0; i<card; ) {
if (maxv && c > maxv) {
- if (minv)
- c = minv;
- else
+ if (!seq->cycle)
break;
+ c = minv;
}
- rb[i] = c;
- if ((i+1) < card)
+ rb[i++] = c;
+ if (i < card)
c += inc;
}
assert(c == end);
diff --git a/sql/test/miscellaneous/Tests/All b/sql/test/miscellaneous/Tests/All
--- a/sql/test/miscellaneous/Tests/All
+++ b/sql/test/miscellaneous/Tests/All
@@ -22,3 +22,4 @@ vessels
prepare
rel_push_count_down
NOT_ASSERT?sqlfuncnames
+sequences
diff --git a/sql/test/miscellaneous/Tests/sequences.test
b/sql/test/miscellaneous/Tests/sequences.test
new file mode 100644
--- /dev/null
+++ b/sql/test/miscellaneous/Tests/sequences.test
@@ -0,0 +1,137 @@
+
+statement ok
+start transaction
+
+statement ok
+create sequence ups START WITH 0 INCREMENT BY 1 MINVALUE 0 MAXVALUE 10 CYCLE
+
+query I nosort
+select next value for ups from generate_series(1,20)
+----
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+0
+1
+2
+3
+4
+5
+6
+7
+
+statement ok
+create sequence ups2 START WITH -10 INCREMENT BY 1 MINVALUE -10 MAXVALUE 0
CYCLE
+
+query I nosort
+select next value for ups2 from generate_series(1,20)
+----
+-10
+-9
+-8
+-7
+-6
+-5
+-4
+-3
+-2
+-1
+0
+-10
+-9
+-8
+-7
+-6
+-5
+-4
+-3
+
+statement ok
+create sequence ups3 START WITH -10 INCREMENT BY -1 MINVALUE -20 MAXVALUE -10
CYCLE
+
+query I nosort
+select next value for ups3 from generate_series(1,20)
+----
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list