MonetDB: default - Merged with Jun2020
Changeset: 75fc8583de89 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=75fc8583de89 Modified Files: sql/server/rel_optimizer.c sql/server/rel_rel.c sql/server/rel_rel.h sql/server/rel_select.c sql/test/SQLancer/Tests/sqlancer03.sql sql/test/SQLancer/Tests/sqlancer03.stable.out Branch: default Log Message: Merged with Jun2020 diffs (101 lines): diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -7537,18 +7537,27 @@ rel_simplify_predicates(visitor *v, sql_ e->l = ie; } else if (is_atom(r->type) && r->l) { /* direct literal */ atom *a = r->l; - int flag = a->data.val.bval; - - assert(list_length(args) == 1); - l = args->h->data; - if (exp_subtype(l)) { - r = exp_atom(v->sql->sa, atom_general(v->sql->sa, exp_subtype(l), NULL)); - e = exp_compare(v->sql->sa, l, r, e->flag); - if (e && !flag) - set_anti(e); - if (e) - set_semantics(e); + + if (a->isnull) { + if (is_semantics(e)) /* isnull(x) = NULL -> false, isnull(x) <> NULL -> true */ + e = exp_atom_bool(v->sql->sa, e->flag == cmp_notequal); + else /* always NULL */ + e = exp_null(v->sql->sa, sql_bind_localtype("bit")); v->changes++; + } else { + int flag = a->data.val.bval; + + assert(list_length(args) == 1); + l = args->h->data; + if (exp_subtype(l)) { + r = exp_atom(v->sql->sa, atom_general(v->sql->sa, exp_subtype(l), NULL)); + e = exp_compare(v->sql->sa, l, r, e->flag); + if (e && !flag) + set_anti(e); + if (e) + set_semantics(e); + v->changes++; + } } } } else if (!f->func->s && is_not_func(f)) { diff --git a/sql/test/SQLancer/Tests/sqlancer03.sql b/sql/test/SQLancer/Tests/sqlancer03.sql --- a/sql/test/SQLancer/Tests/sqlancer03.sql +++ b/sql/test/SQLancer/Tests/sqlancer03.sql @@ -1,1 +1,17 @@ select splitpart(r'%Fz晟2墁', '', 1), splitpart(r'%Fz晟2墁', r'', 2), splitpart(r'%Fz晟2墁', r'', 1271186887); + +START TRANSACTION; -- Bug 6916 +CREATE TABLE "t0" ("c0" BOOLEAN NOT NULL,"c1" SMALLINT NOT NULL,CONSTRAINT "t0_c0_c1_pkey" PRIMARY KEY ("c0", "c1")); +INSERT INTO "t0" VALUES (false, -1); +create view v0(c0, c1, c2, c3) as (select ((t0.c1)<<(cast(0.09114074486978418487836961503489874303340911865234375 as int))), 0.4088967652609865, 0.3848869389602949109274732109042815864086151123046875, t0.c0 from t0 where t0.c0); + +SELECT v0.c0 FROM t0 FULL OUTER JOIN v0 ON t0.c0; + -- NULL +SELECT v0.c0 FROM t0 FULL OUTER JOIN v0 ON t0.c0 WHERE (rtrim(((upper(''))||(v0.c1 IS NULL; + -- NULL +SELECT v0.c0 FROM t0 FULL OUTER JOIN v0 ON t0.c0 WHERE NOT ((rtrim(((upper(''))||(v0.c1 IS NULL); + -- empty +SELECT v0.c0 FROM t0 FULL OUTER JOIN v0 ON t0.c0 WHERE ((rtrim(((upper(''))||(v0.c1 IS NULL) IS NULL; + -- empty + +ROLLBACK; diff --git a/sql/test/SQLancer/Tests/sqlancer03.stable.out b/sql/test/SQLancer/Tests/sqlancer03.stable.out --- a/sql/test/SQLancer/Tests/sqlancer03.stable.out +++ b/sql/test/SQLancer/Tests/sqlancer03.stable.out @@ -11,6 +11,34 @@ stdout of test 'sqlancer03` in directory % clob,
MonetDB: default - Merged with Jun2020
Changeset: 7a95a118e182 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7a95a118e182 Added Files: sql/test/SQLancer/Tests/sqlancer03.sql sql/test/SQLancer/Tests/sqlancer03.stable.err sql/test/SQLancer/Tests/sqlancer03.stable.out Modified Files: monetdb5/modules/atoms/str.c sql/storage/store.c sql/test/SQLancer/Tests/All Branch: default Log Message: Merged with Jun2020 diffs (105 lines): diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c --- a/monetdb5/modules/atoms/str.c +++ b/monetdb5/modules/atoms/str.c @@ -3565,7 +3565,7 @@ STRsplitpart(str *res, str *haystack, st { size_t len; int f = *field; - char *p; + char *p = NULL; const char *s = *haystack; const char *s2 = *needle; @@ -3581,10 +3581,11 @@ STRsplitpart(str *res, str *haystack, st } len = strlen(s2); - - while ((p = strstr(s, s2)) != NULL && f > 1) { - s = p + len; - f--; + if (len) { + while ((p = strstr(s, s2)) != NULL && f > 1) { + s = p + len; + f--; + } } if (f != 1) { diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -3511,9 +3511,8 @@ table_dup(sql_trans *tr, int flags, sql_ /* Needs copy when committing (ie from tr to gtrans) and * on savepoints from tr->parent to new tr */ if (flags) { + assert(t->data == NULL); t->base.allocated = ot->base.allocated; - if (ot->data) - (void)store_funcs.destroy_del(tr, ot); t->data = ot->data; ot->base.allocated = 0; ot->data = NULL; @@ -3783,7 +3782,8 @@ trans_init(sql_trans *tr, backend_stack t->base.rtime = t->base.wtime = 0; t->base.stime = pt->base.wtime; if (!istmp && !t->base.allocated) { - (void)store_funcs.destroy_del(tr, t); + if (t->data) + (void)store_funcs.destroy_del(tr, t); t->data = NULL; } assert (istmp || !t->base.allocated); diff --git a/sql/test/SQLancer/Tests/All b/sql/test/SQLancer/Tests/All --- a/sql/test/SQLancer/Tests/All +++ b/sql/test/SQLancer/Tests/All @@ -1,2 +1,3 @@ sqlancer01 sqlancer02 +sqlancer03 diff --git a/sql/test/SQLancer/Tests/sqlancer03.sql b/sql/test/SQLancer/Tests/sqlancer03.sql new file mode 100644 --- /dev/null +++ b/sql/test/SQLancer/Tests/sqlancer03.sql @@ -0,0 +1,1 @@ +select splitpart(r'%Fz晟2墁', '', 1), splitpart(r'%Fz晟2墁', r'', 2), splitpart(r'%Fz晟2墁', r'', 1271186887); diff --git a/sql/test/SQLancer/Tests/sqlancer03.stable.err b/sql/test/SQLancer/Tests/sqlancer03.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/SQLancer/Tests/sqlancer03.stable.err @@ -0,0 +1,12 @@ +stderr of test 'sqlancer03` in directory 'sql/test/SQLancer` itself: + + +# 17:14:16 > +# 17:14:16 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-439482" "--port=37916" +# 17:14:16 > + + +# 17:14:16 > +# 17:14:16 > "Done." +# 17:14:16 > + diff --git a/sql/test/SQLancer/Tests/sqlancer03.stable.out b/sql/test/SQLancer/Tests/sqlancer03.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/SQLancer/Tests/sqlancer03.stable.out @@ -0,0 +1,18 @@ +stdout of test 'sqlancer03` in directory 'sql/test/SQLancer` itself: + + +# 17:14:16 > +# 17:14:16 > "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-439482" "--port=37916" +# 17:14:16 > + +#select splitpart(r'%Fz晟2墁', '', 1), splitpart(r'%Fz晟2墁', r'', 2), splitpart(r'%Fz晟2墁', r'', 1271186887); +% .%2, .%3,.%4 # table_name +% %2, %3, %4 # name +% clob,clob, varchar # type +% 9, 0, 0 # length +[ "%Fz晟2墁", "", "" ] + +# 17:14:16 > +# 17:14:16 > "Done." +# 17:14:16 > + ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Merged with Jun2020
Changeset: a9f4aa006d3b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a9f4aa006d3b Modified Files: monetdb5/modules/kernel/algebra.c sql/backends/monet5/sql_statement.c sql/server/rel_unnest.c sql/storage/bat/bat_storage.c sql/storage/store.c sql/test/BugTracker-2016/Tests/storagemodel.stable.out sql/test/mapi/Tests/utf8test.SQL.py sql/test/subquery/Tests/subquery4.sql sql/test/subquery/Tests/subquery4.stable.out sql/test/subquery/Tests/subquery6.sql sql/test/subquery/Tests/subquery6.stable.err sql/test/subquery/Tests/subquery6.stable.out testing/Mtest.py.in testing/process.py Branch: default Log Message: Merged with Jun2020 diffs (truncated from 983 to 300 lines): diff --git a/monetdb5/modules/kernel/algebra.c b/monetdb5/modules/kernel/algebra.c --- a/monetdb5/modules/kernel/algebra.c +++ b/monetdb5/modules/kernel/algebra.c @@ -1189,9 +1189,17 @@ ALGfetch(ptr ret, const bat *bid, const if ((b = BATdescriptor(*bid)) == NULL) { throw(MAL, "algebra.fetch", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); } - if ((*pos < (lng) 0) || (*pos >= (lng) BUNlast(b))) { + if (*pos < (lng) 0) { + BBPunfix(b->batCacheid); + throw(MAL, "algebra.fetch", ILLEGAL_ARGUMENT ": row index to fetch must be non negative\n"); + } + if (BATcount(b) == 0) { BBPunfix(b->batCacheid); - throw(MAL, "algebra.fetch", ILLEGAL_ARGUMENT " Idx out of range\n"); + throw(MAL, "algebra.fetch", ILLEGAL_ARGUMENT ": cannot fetch a single row from an empty input\n"); + } + if (*pos >= (lng) BUNlast(b)) { + BBPunfix(b->batCacheid); + throw(MAL, "algebra.fetch", ILLEGAL_ARGUMENT ": row index to fetch is out of range\n"); } msg = doALGfetch(ret, b, (BUN) *pos); BBPunfix(b->batCacheid); 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 @@ -3963,13 +3963,22 @@ const_column(backend *be, stmt *val) stmt * stmt_fetch(backend *be, stmt *val) { - sql_subtype *ct = tail_type(val); + sql_subtype *ct; MalBlkPtr mb = be->mb; InstrPtr q = NULL; - int tt = ct->type->localtype; + int tt; if (val->nr < 0) return NULL; + /* pick from first column on a table case */ + if (val->type == st_table) { + if (list_length(val->op1->op4.lval) > 1) + return NULL; + val = val->op1->op4.lval->h->data; + } + ct = tail_type(val); + tt = ct->type->localtype; + q = newStmt(mb, algebraRef, fetchRef); if (q == NULL) return NULL; diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c --- a/sql/server/rel_unnest.c +++ b/sql/server/rel_unnest.c @@ -1569,8 +1569,19 @@ rewrite_inner(mvc *sql, sql_rel *rel, sq static sql_exp * rewrite_exp_rel(visitor *v, sql_rel *rel, sql_exp *e, int depth) { - (void)depth; - if (exp_has_rel(e) && !is_ddl(rel->op)) { + if (exp_is_rel(e) && is_ddl(rel->op) && rel->flag == ddl_psm) { + sql_rel *inner = exp_rel_get_rel(v->sql->sa, e); + if (is_single(inner)) { + /* use a dummy projection for the single join */ + sql_rel *nrel = rel_project(v->sql->sa, NULL, append(sa_list(v->sql->sa), exp_atom_bool(v->sql->sa, 1))); + + if (!rewrite_inner(v->sql, nrel, inner, depth?op_left:op_join)) + return NULL; + /* has to apply recursively */ + if (!(e->l = rel_exp_visitor_bottomup(v, nrel, _exp_rel))) + return NULL; + } + } else if (exp_has_rel(e) && !is_ddl(rel->op)) { sql_exp *ne = rewrite_inner(v->sql, rel, exp_rel_get_rel(v->sql->sa, e), depth?op_left:op_join); if (!ne) @@ -1586,9 +1597,6 @@ rewrite_exp_rel(visitor *v, sql_rel *rel e = exp_rel_update_exp(v->sql, e); } } - if (exp_is_rel(e) && is_ddl(rel->op)) - if (!(e->l = rel_exp_visitor_bottomup(v, e->l, _exp_rel))) - return NULL; return e; } @@ -2104,7 +2112,7 @@ static sql_exp * rewrite_anyequal(mvc *sql, sql_rel *rel, sql_exp *e, int depth) { sql_subfunc *sf; - if (e->type != e_func || is_ddl(rel->op)) + if (e->type != e_func) return e; sf = e->f; @@ -2236,6 +2244,8 @@ rewrite_anyequal(mvc *sql, sql_rel *rel, if (exp_name(e)) exp_prop_alias(sql->sa, le, e);
MonetDB: default - Merged with Jun2020
Changeset: a6023133240b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a6023133240b Modified Files: sql/backends/monet5/sql.c sql/backends/monet5/sql_upgrades.c sql/server/rel_exp.c sql/server/rel_exp.h sql/server/rel_optimizer.c sql/server/rel_propagate.c sql/server/rel_psm.c sql/server/rel_schema.c sql/server/rel_select.c sql/server/rel_select.h sql/server/rel_sequence.c sql/server/rel_unnest.c sql/server/rel_updates.c sql/server/rel_xml.c sql/server/sql_atom.c sql/server/sql_atom.h sql/test/SQLancer/Tests/All sql/test/SQLancer/Tests/sqlancer02.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 1405 to 300 lines): 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 @@ -326,7 +326,7 @@ create_table_or_view(mvc *sql, char* sna } r = rel_parse(sql, s, sa_message(sql->sa, "select %s;", c->def), m_deps); if (!r || !is_project(r->op) || !r->exps || list_length(r->exps) != 1 || - rel_check_type(sql, >type, r, r->exps->h->data, type_equal) == NULL) { + exp_check_type(sql, >type, r, r->exps->h->data, type_equal) == NULL) { if (r) rel_destroy(r); sa_destroy(sql->sa); 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 @@ -2548,40 +2548,6 @@ sql_update_jun2020(Client c, mvc *sql, c " external name \"sql\".\"corr\";\n" "GRANT EXECUTE ON WINDOW corr(INTERVAL MONTH, INTERVAL MONTH) TO PUBLIC;\n"); -#ifdef HAVE_HGE - if (have_hge) { - /* 39_analytics_hge.sql */ - pos += snprintf(buf + pos, bufsize - pos, - "create window stddev_samp(val HUGEINT) returns DOUBLE\n" - " external name \"sql\".\"stdev\";\n" - "GRANT EXECUTE ON WINDOW stddev_samp(HUGEINT) TO PUBLIC;\n" - "create window stddev_pop(val HUGEINT) returns DOUBLE\n" - " external name \"sql\".\"stdevp\";\n" - "GRANT EXECUTE ON WINDOW stddev_pop(HUGEINT) TO PUBLIC;\n" - "create window var_samp(val HUGEINT) returns DOUBLE\n" - " external name \"sql\".\"variance\";\n" - "GRANT EXECUTE ON WINDOW var_samp(HUGEINT) TO PUBLIC;\n" - "create window var_pop(val HUGEINT) returns DOUBLE\n" - " external name \"sql\".\"variancep\";\n" - "GRANT EXECUTE ON WINDOW var_pop(HUGEINT) TO PUBLIC;\n" - "create aggregate covar_samp(e1 HUGEINT, e2 HUGEINT) returns DOUBLE\n" - " external name \"aggr\".\"covariance\";\n" - "GRANT EXECUTE ON AGGREGATE covar_samp(HUGEINT, HUGEINT) TO PUBLIC;\n" - "create window covar_samp(e1 HUGEINT, e2 HUGEINT) returns DOUBLE\n" - " external name \"sql\".\"covariance\";\n" - "GRANT EXECUTE ON WINDOW covar_samp(HUGEINT, HUGEINT) TO PUBLIC;\n" - "create aggregate covar_pop(e1 HUGEINT, e2 HUGEINT) returns DOUBLE\n" - " external name \"aggr\".\"covariancep\";\n" - "GRANT EXECUTE ON AGGREGATE covar_pop(HUGEINT, HUGEINT) TO PUBLIC;\n" - "create window covar_pop(e1 HUGEINT, e2 HUGEINT) returns DOUBLE\n" - " external name \"sql\".\"covariancep\";\n" - "GRANT EXECUTE ON WINDOW covar_pop(HUGEINT, HUGEINT) TO PUBLIC;\n" - "create window corr(e1 HUGEINT, e2 HUGEINT) returns DOUBLE\n" - " external name \"sql\".\"corr\";\n" - "GRANT EXECUTE ON WINDOW corr(HUGEINT, HUGEINT) TO PUBLIC;\n"); - } -#endif - pos += snprintf(buf + pos, bufsize - pos, "create window sys.group_concat(str STRING) returns STRING\n" " external name \"sql\".\"str_group_concat\";\n" diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c --- a/sql/server/rel_exp.c +++ b/sql/server/rel_exp.c @@ -498,6 +498,13 @@ exp_null(sql_allocator *sa, sql_subtype return exp_atom(sa, a); } +sql_exp * +exp_zero(sql_allocator *sa, sql_subtype *tpe) +{ + atom *a = atom_zero_value(sa, tpe); + return exp_atom(sa, a); +} + atom * exp_value(mvc *sql, sql_exp *e, atom **args, int maxarg) { @@ -2759,6 +2766,205 @@ exps_reset_freevar(list *exps)
MonetDB: default - Merged with Jun2020
Changeset: 63d49ec1360c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=63d49ec1360c Modified Files: sql/server/sql_atom.c sql/test/miscellaneous/Tests/simple_selects.sql sql/test/miscellaneous/Tests/simple_selects.stable.err Branch: default Log Message: Merged with Jun2020 ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Merged with Jun2020
Changeset: d6603b58032b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d6603b58032b Modified Files: sql/backends/monet5/sql.c sql/backends/monet5/sql_time.c sql/test/mapi/Tests/sql_dec38.sql sql/test/mapi/Tests/sql_int128.sql sql/test/miscellaneous/Tests/simple_selects.sql sql/test/miscellaneous/Tests/simple_selects.stable.err sql/test/miscellaneous/Tests/simple_selects.stable.out Branch: default Log Message: Merged with Jun2020 diffs (83 lines): diff --git a/sql/backends/monet5/sql_time.c b/sql/backends/monet5/sql_time.c --- a/sql/backends/monet5/sql_time.c +++ b/sql/backends/monet5/sql_time.c @@ -1104,9 +1104,7 @@ second_interval(Client cntxt, MalBlkPtr } if (scale) { #ifndef TRUNCATE_NUMBERS - shift = scales[scale] >> 1; -#else - (void) shift; + shift += 5*scales[scale-1]; #endif divider = scales[scale]; } diff --git a/sql/test/mapi/Tests/sql_dec38.sql b/sql/test/mapi/Tests/sql_dec38.sql --- a/sql/test/mapi/Tests/sql_dec38.sql +++ b/sql/test/mapi/Tests/sql_dec38.sql @@ -2,3 +2,4 @@ START TRANSACTION; CREATE TABLE sql_dec38 (d38_0 DECIMAL(38,0), d38_19 DECIMAL(38,19), d38_38 DECIMAL(38,38)); INSERT INTO sql_dec38 VALUES (12345678901234567899876543210987654321, 1234567890123456789.9876543210987654321, .12345678901234567899876543210987654321); SELECT * FROM sql_dec38; +ROLLBACK; diff --git a/sql/test/mapi/Tests/sql_int128.sql b/sql/test/mapi/Tests/sql_int128.sql --- a/sql/test/mapi/Tests/sql_int128.sql +++ b/sql/test/mapi/Tests/sql_int128.sql @@ -19,3 +19,4 @@ CREATE TABLE sql_int128 (i HUGEINT); explain INSERT INTO sql_int128 VALUES (123456789098765432101234567890987654321); INSERT INTO sql_int128 VALUES (123456789098765432101234567890987654321); SELECT * FROM sql_int128; +ROLLBACK; diff --git a/sql/test/miscellaneous/Tests/simple_selects.sql b/sql/test/miscellaneous/Tests/simple_selects.sql --- a/sql/test/miscellaneous/Tests/simple_selects.sql +++ b/sql/test/miscellaneous/Tests/simple_selects.sql @@ -179,3 +179,6 @@ select 'a' like 'a' escape 'a'; --error, select cast(x as interval second) from (values ('1'), (NULL), ('100'), (NULL)) as x(x); select cast(x as interval month) from (values ('1'), (NULL), ('100'), (NULL)) as x(x); + +select cast(9223372036854775808 as interval month); --error value to large for a month interval +select cast(92233720368547750 as interval second); --error, overflow in conversion for interval second diff --git a/sql/test/miscellaneous/Tests/simple_selects.stable.err b/sql/test/miscellaneous/Tests/simple_selects.stable.err --- a/sql/test/miscellaneous/Tests/simple_selects.stable.err +++ b/sql/test/miscellaneous/Tests/simple_selects.stable.err @@ -198,6 +198,14 @@ MAPI = (monetdb) /var/tmp/mtest-400226/ QUERY = select 'a' like 'a' escape 'a'; --error, like sequence ending with escape character ERROR = !Illegal argument: (I)LIKE pattern must not end with escape character CODE = 22019 +MAPI = (monetdb) /var/tmp/mtest-107867/.s.monetdb.37815 +QUERY = select cast(9223372036854775808 as interval month); --error value to large for a month interval +ERROR = !Value 9223372036854775808 too large to fit at a month_interval +CODE = 22003 +MAPI = (monetdb) /var/tmp/mtest-107867/.s.monetdb.37815 +QUERY = select cast(92233720368547750 as interval second); --error, overflow in conversion for interval second +ERROR = !Overflow in convertion of 92233720368547750 to sec_interval +CODE = 22003 # 17:31:38 > # 17:31:38 > "Done." diff --git a/sql/test/miscellaneous/Tests/simple_selects.stable.out b/sql/test/miscellaneous/Tests/simple_selects.stable.out --- a/sql/test/miscellaneous/Tests/simple_selects.stable.out +++ b/sql/test/miscellaneous/Tests/simple_selects.stable.out @@ -354,8 +354,8 @@ stdout of test 'simple_selects` in direc #create table x (a int GENERATED ALWAYS AS IDENTITY); #alter table x alter a set default 1; --ok, remove sequence #SELECT CAST(COUNT(*) - (SELECT m FROM myvar) AS BIGINT) FROM sequences; --the total count, cannot change -% .%4 # table_name -% %4 # name +% .%3 # table_name +% %3 # name % bigint # type % 1 # length [ 0] @@ -367,8 +367,8 @@ stdout of test 'simple_selects` in direc #create table x (a int GENERATED ALWAYS AS IDENTITY); #alter table x alter a drop default; --ok, remove sequence #SELECT CAST(COUNT(*) - (SELECT m FROM myvar) AS BIGINT) FROM sequences; --the total count, cannot change -% .%4 # table_name -% %4 # name +% .%3 # table_name +% %3 # name % bigint # type % 1 # length [ 0] ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Merged with Jun2020
Changeset: c920a864d72a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c920a864d72a Modified Files: gdk/gdk_string.c sql/storage/bat/bat_logger.c sql/test/BugDay_2005-10-06_2.8/Tests/mixed_type.SF-917372.sql sql/test/BugDay_2005-10-06_2.8/Tests/mixed_type.SF-917372.stable.out sql/test/BugTracker-2011/Tests/CASE_nested_functions.Bug-2852.sql sql/test/BugTracker-2011/Tests/CASE_nested_functions.Bug-2852.stable.out sql/test/BugTracker-2017/Tests/one-plus-nil.Bug-6243.sql sql/test/BugTracker-2017/Tests/one-plus-nil.Bug-6243.stable.out sql/test/SQLancer/Tests/sqlancer02.sql sql/test/analytics/Tests/analytics17.stable.out sql/test/group-concat/Tests/groupconcat05.sql sql/test/group-concat/Tests/groupconcat05.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 658 to 300 lines): diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c --- a/gdk/gdk_string.c +++ b/gdk/gdk_string.c @@ -866,8 +866,8 @@ concat_strings(BAT **bnp, ValPtr pt, BAT } canditer_reset(ci); - if (nils == 0) { - char *single_str; + if (nils == 0 && !empty) { + char *single_str = NULL; if ((single_str = GDKmalloc(single_length + 1)) == NULL) return GDK_FAIL; @@ -1185,6 +1185,7 @@ GDKanalytical_str_group_concat(BAT *r, B str sb, sl, single_str = NULL, next_single_str; bool empty; size_t separator_length = 0, next_group_length, max_group_length = 0, next_length, offset; + bool hasnil = 0; assert(s && e && ((sep && !separator && BATcount(b) == BATcount(sep)) || (!sep && separator))); start = (lng *) Tloc(s, 0); @@ -1235,61 +1236,65 @@ GDKanalytical_str_group_concat(BAT *r, B } } - empty = true; - - if (!single_str) { /* reuse the same buffer, resize it when needed */ - max_group_length = next_group_length; - if ((single_str = GDKmalloc(max_group_length + 1)) == NULL) - goto allocation_error; - } else if (next_group_length > max_group_length) { - max_group_length = next_group_length; - if ((next_single_str = GDKrealloc(single_str, max_group_length + 1)) == NULL) + if (empty) { + if ((single_str = GDKstrdup(str_nil)) == NULL) goto allocation_error; - single_str = next_single_str; - } + hasnil = true; + } else { + empty = true; + if (!single_str) { /* reuse the same buffer, resize it when needed */ + max_group_length = next_group_length; + if ((single_str = GDKmalloc(max_group_length + 1)) == NULL) + goto allocation_error; + } else if (next_group_length > max_group_length) { + max_group_length = next_group_length; + if ((next_single_str = GDKrealloc(single_str, max_group_length + 1)) == NULL) + goto allocation_error; + single_str = next_single_str; + } - for (j = start[i]; j < l; j++) { - sb = BUNtvar(bi, (BUN) j); + for (j = start[i]; j < l; j++) { + sb = BUNtvar(bi, (BUN) j); - if (separator) { - if (strNil(sb)) - continue; - if (!empty) { - memcpy(single_str + offset, separator, separator_length); - offset += separator_length; + if (separator) { + if (strNil(sb)) + continue; + if (!empty) { + memcpy(single_str + offset, separator, separator_length); + offset += separator_length; + } + next_length = strlen(sb); + memcpy(single_str + offset, sb, next_length); + offset += next_length; + empty = false; + } else { /* sep case */ + assert(sep != NULL); +
MonetDB: default - Merged with Jun2020
Changeset: 4c465199b13a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4c465199b13a Modified Files: sql/backends/monet5/sql.c sql/backends/monet5/sql_round_impl.h sql/server/rel_select.c sql/test/BugDay_2005-10-06_2.8/Tests/mixed_type.SF-917372.stable.err sql/test/BugDay_2005-10-06_2.8/Tests/mixed_type.SF-917372.stable.out sql/test/BugTracker-2011/Tests/CASE_nested_functions.Bug-2852.stable.out sql/test/BugTracker-2012/Tests/incorrect_cast_from_double_to_int.Bug-2579.stable.err sql/test/BugTracker-2012/Tests/incorrect_cast_from_double_to_int.Bug-2579.stable.out sql/test/BugTracker-2012/Tests/interval_timestamp.Bug-3002.stable.err sql/test/BugTracker-2017/Tests/one-plus-nil.Bug-6243.stable.out sql/test/Skyserver/Skyserver_functions.sql sql/test/Skyserver/Skyserver_functions_v6.sql sql/test/miscellaneous/Tests/simple_selects.sql sql/test/miscellaneous/Tests/simple_selects.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 453 to 300 lines): diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -1455,6 +1455,25 @@ rel_numeric_supertype(mvc *sql, sql_exp return e; } +static sql_subtype* +largest_numeric_type(sql_subtype *res, int ec) +{ + if (ec == EC_NUM) { +#ifdef HAVE_HGE + *res = *sql_bind_localtype(have_hge ? "hge" : "lng"); +#else + *res = *sql_bind_localtype("lng"); +#endif + return res; + } + if (ec == EC_DEC && sql_find_subtype(res, "decimal", 38, 0)) { + /* we don't know the precision nor scale ie we use a double */ + *res = *sql_bind_localtype("dbl"); + return res; + } + return NULL; +} + sql_exp * rel_check_type(mvc *sql, sql_subtype *t, sql_rel *rel, sql_exp *exp, check_type tpe) { @@ -3068,6 +3087,10 @@ rel_unop(sql_query *query, sql_rel **rel #define is_addition(fname) (strcmp(fname, "sql_add") == 0) #define is_subtraction(fname) (strcmp(fname, "sql_sub") == 0) +#define is_multiplication(fname) (strcmp(fname, "sql_mul") == 0) +#define is_division(fname) (strcmp(fname, "sql_div") == 0) + +#define is_numeric_dyadic_func(fname) (is_addition(fname) || is_subtraction(fname) || is_multiplication(fname) || is_division(fname)) sql_exp * rel_binop_(mvc *sql, sql_rel *rel, sql_exp *l, sql_exp *r, sql_schema *s, char *fname, int card) @@ -3128,6 +3151,31 @@ rel_binop_(mvc *sql, sql_rel *rel, sql_e r = res; } } + if (!f) { + if (is_numeric_dyadic_func(fname)) { + if (EC_NUMBER(t1->type->eclass) && !EC_NUMBER(t2->type->eclass)) { + sql_subtype tp; + if (!largest_numeric_type(, t1->type->eclass)) + tp = *t1; /* for float and interval fall back too the same as left */ + r = rel_check_type(sql, , rel, r, type_equal); + if (!r) + return NULL; + t2 = exp_subtype(r); + } else if (!EC_NUMBER(t1->type->eclass) && !EC_TEMP(t1->type->eclass) && EC_NUMBER(t2->type->eclass)) { + sql_subtype tp; + if (!largest_numeric_type(, t2->type->eclass)) + tp = *t2; /* for float and interval fall back too the same as right */ + l = rel_check_type(sql, , rel, l, type_equal); + if (!l) + return NULL; + t1 = exp_subtype(l); + } else if (!EC_NUMBER(t1->type->eclass) && !EC_TEMP(t1->type->eclass) && !EC_NUMBER(t2->type->eclass)) { + return sql_error(sql, 02, SQLSTATE(42000) "SELECT: no such binary operator '%s(%s,%s)'", fname, + exp_subtype(l)->type->sqlname, + exp_subtype(r)->type->sqlname); + } + } + } if (f && check_card(card,f)) { if (f->func->fix_scale == SCALE_FIX) { l = exp_fix_scale(sql, t2, l, 0, 0); diff --git a/sql/test/BugDay_2005-10-06_2.8/Tests/mixed_type.SF-917372.stable.err b/sql/test/BugDay_2005-10-06_2.8/Tests/mixed_type.SF-917372.stable.err --- a/sql/test/BugDay_2005-10-06_2.8/Tests/mixed_type.SF-917372.stable.err +++ b/sql/test/BugDay_2005-10-06_2.8/Tests/mixed_type.SF-917372.stable.err @@ -81,11 +81,11 @@ stderr of test 'mixed_type.SF-917372` in MAPI = (monetdb) /var/tmp/mtest-10022/.s.monetdb.31381 QUERY = select 'a'+1; -ERROR = !Daytime (a) has
MonetDB: default - Merged with Jun2020
Changeset: 086a22d16139 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=086a22d16139 Added Files: sql/test/astro/Tests/All sql/test/astro/Tests/drop.sql sql/test/astro/Tests/drop.stable.err sql/test/astro/Tests/drop.stable.out sql/test/astro/Tests/schema.sql sql/test/astro/Tests/schema.stable.err sql/test/astro/Tests/schema.stable.out sql/test/astro/Tests/update.sql sql/test/astro/Tests/update.stable.err sql/test/astro/Tests/update.stable.out Modified Files: common/utils/mstring.h sql/backends/monet5/vaults/shp/shp.h sql/server/rel_unnest.c sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out sql/test/BugTracker-2016/Tests/storagemodel.stable.out sql/test/SQLancer/Tests/sqlancer02.sql sql/test/subquery/Tests/subquery6.sql Branch: default Log Message: Merged with Jun2020 diffs (truncated from 618 to 300 lines): diff --git a/common/utils/mstring.h b/common/utils/mstring.h --- a/common/utils/mstring.h +++ b/common/utils/mstring.h @@ -30,6 +30,11 @@ strcpy_len(char *restrict dst, const cha return i; } dst[n - 1] = 0; +/* in some versions of GCC (at least gcc (Ubuntu 7.5.0-3ubuntu1~18.04) + * 7.5.0), the error just can't be turned off when using + * --enable-strict, so we just use the (more) expensive way of getting the + * right answer (rescan the whole string) */ +#if !defined(__GNUC__) || __GNUC__ > 7 || (__GNUC__ == 7 && __GNUC_MINOR__ > 5) /* This code is correct, but GCC gives a warning in certain * conditions, so we disable the warning temporarily. * The warning happens e.g. in @@ -44,6 +49,7 @@ GCC_Pragma("GCC diagnostic push") GCC_Pragma("GCC diagnostic ignored \"-Warray-bounds\"") return n + strlen(src + n); GCC_Pragma("GCC diagnostic pop") +#endif } return strlen(src); } diff --git a/sql/backends/monet5/vaults/shp/shp.h b/sql/backends/monet5/vaults/shp/shp.h --- a/sql/backends/monet5/vaults/shp/shp.h +++ b/sql/backends/monet5/vaults/shp/shp.h @@ -23,7 +23,7 @@ #undef HAVE_FCNTL_H #undef HAVE_ICONV #undef HAVE_STRINGS_H - +#undef HAVE_CXX11 #include #include diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c --- a/sql/server/rel_unnest.c +++ b/sql/server/rel_unnest.c @@ -1213,6 +1213,16 @@ push_up_select_l(mvc *sql, sql_rel *rel) static sql_rel * push_up_join(mvc *sql, sql_rel *rel, list *ad) { + if (rel && (is_join(rel->op) || is_semi(rel->op)) && is_dependent(rel)) { + sql_rel *j = rel->r; + + if (j->op == op_join && !rel_is_ref(rel) && !rel_is_ref(j) && j->exps) { + rel->exps = rel->exps?list_merge(rel->exps, j->exps, (fdup)NULL):j->exps; + j->exps = NULL; + return rel; + } + } + /* input rel is dependent join with on the right a project */ if (rel && (is_join(rel->op) || is_semi(rel->op)) && is_dependent(rel)) { sql_rel *d = rel->l, *j = rel->r; @@ -1439,6 +1449,18 @@ rel_unnest_dependent(mvc *sql, sql_rel * if (rel_has_freevar(sql, r)) { list *ad = rel_dependent_var(sql, rel->l, rel->r); + if (r && is_select(r->op)) { + sql_rel *l = r->l; + + if (!rel_is_ref(r) && l && !rel_is_ref(l) && l->op == op_join && list_empty(l->exps)) { + l->exps = r->exps; + r->l = NULL; + rel_destroy(r); + rel->r = l; + return rel_unnest_dependent(sql, rel); + } + } + if (r && is_simple_project(r->op) && ((!exps_have_freevar(sql, r->exps) && !exps_have_analytics(sql, r->exps)) || is_distinct_set(sql, l, ad))) { rel = push_up_project(sql, rel, ad); return rel_unnest_dependent(sql, rel); diff --git a/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out b/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out --- a/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out +++ b/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out @@ -74,28 +74,30 @@ join ( | table(sys.bidder) [ "bidder"."id" NOT NULL HASHCOL as "b"."id", "bidder"."open_auction_id" NOT NULL as "b"."open_auction_id", "bidder"."date" NOT NULL as "b"."date", "bidder"."time" NOT NULL as "b"."time", "bidder"."personref" NOT NULL as "b"."personref", "bidder"."increase" NOT NULL as "b"."increase", "bidder"."%TID%" NOT NULL as "b"."%TID%" ] COUNT ) [ "o"."open_auction_id" NOT NULL = "b"."open_auction_id" NOT NULL ] REF 2 (2) -single join ( -| & REF
MonetDB: default - Merged with Jun2020
Changeset: 77ff6e9bae1e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=77ff6e9bae1e Added Files: sql/test/miscellaneous/Tests/vessels.sql sql/test/miscellaneous/Tests/vessels.stable.err sql/test/miscellaneous/Tests/vessels.stable.out Modified Files: sql/server/rel_exp.c sql/server/rel_exp.h sql/server/rel_psm.c sql/server/rel_rel.c sql/server/rel_rel.h sql/server/rel_select.c sql/server/rel_unnest.c sql/server/sql_parser.y sql/test/BugTracker-2015/Tests/window_function_crash.Bug-3861.stable.err sql/test/miscellaneous/Tests/All sql/test/pg_regress/Tests/arrays.stable.err sql/test/subquery/Tests/subquery4.stable.err sql/test/subquery/Tests/subquery6.sql sql/test/subquery/Tests/subquery6.stable.err sql/test/subquery/Tests/subquery6.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 968 to 300 lines): diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c --- a/sql/server/rel_exp.c +++ b/sql/server/rel_exp.c @@ -155,8 +155,6 @@ exp_compare(sql_allocator *sa, sql_exp * if (e == NULL) return NULL; e->card = MAX(l->card,r->card); - if (e->card == CARD_ATOM && !exp_is_atom(l)) - e->card = CARD_AGGR; e->l = l; e->r = r; e->flag = cmptype; @@ -169,12 +167,10 @@ exp_compare2(sql_allocator *sa, sql_exp sql_exp *e = exp_create(sa, e_cmp); if (e == NULL) return NULL; + assert(f); e->card = MAX(MAX(l->card,r->card),f->card); - if (e->card == CARD_ATOM && !exp_is_atom(l)) - e->card = CARD_AGGR; e->l = l; e->r = r; - assert(f); e->f = f; e->flag = cmptype; return e; @@ -252,30 +248,19 @@ exp_in_func(mvc *sql, sql_exp *le, sql_e } sql_exp * -exp_compare_func(mvc *sql, sql_exp *le, sql_exp *re, sql_exp *oe, const char *compareop, int quantifier) +exp_compare_func(mvc *sql, sql_exp *le, sql_exp *re, const char *compareop, int quantifier) { - sql_subfunc *cmp_func = NULL; + sql_subfunc *cmp_func = sql_bind_func(sql->sa, NULL, compareop, exp_subtype(le), exp_subtype(le), F_FUNC); sql_exp *e; - - if (!oe) { - cmp_func = sql_bind_func(sql->sa, NULL, compareop, exp_subtype(le), exp_subtype(le), F_FUNC); - assert(cmp_func); - e = exp_binop(sql->sa, le, re, cmp_func); - } else { - list *types = sa_list(sql->sa), *args = sa_list(sql->sa); - append(types, exp_subtype(le)); - append(types, exp_subtype(le)); - append(types, exp_subtype(le)); - append(args, le); - append(args, re); - append(args, oe); - cmp_func = sql_bind_func_(sql->sa, NULL, compareop, types, F_FUNC); - assert(cmp_func); - e = exp_op(sql->sa, args, cmp_func); - } + + assert(cmp_func); + e = exp_binop(sql->sa, le, re, cmp_func); if (e) { e->flag = quantifier; - e->card = le->card; + if (quantifier) + e->card = le->card; /* At ANY and ALL operators, the cardinality on the right side is ignored */ + else + e->card = MAX(le->card, re->card); } return e; } @@ -314,8 +299,6 @@ exp_op( sql_allocator *sa, list *l, sql_ if (e == NULL) return NULL; e->card = exps_card(l); - if (!l || list_length(l) == 0) - e->card = CARD_ATOM; /* unop returns a single atom */ e->l = l; e->f = f; e->semantics = f->func->semantics; @@ -336,8 +319,6 @@ exp_rank_op( sql_allocator *sa, list *l, if (e == NULL) return NULL; e->card = exps_card(l); - if (!l || list_length(l) == 0) - e->card = CARD_ATOM; /* unop returns a single atom */ e->l = l; e->r = append(append(sa_list(sa), gbe), obe); e->f = f; diff --git a/sql/server/rel_exp.h b/sql/server/rel_exp.h --- a/sql/server/rel_exp.h +++ b/sql/server/rel_exp.h @@ -36,7 +36,7 @@ extern sql_exp *exp_filter(sql_allocator extern sql_exp *exp_or(sql_allocator *sa, list *l, list *r, int anti); extern sql_exp *exp_in(sql_allocator *sa, sql_exp *l, list *r, int cmptype); extern sql_exp *exp_in_func(mvc *sql, sql_exp *le, sql_exp *vals, int anyequal, int is_tuple); -extern sql_exp *exp_compare_func(mvc *sql, sql_exp *le, sql_exp *re, sql_exp *oe, const char *compareop, int quantifier); +extern sql_exp *exp_compare_func(mvc *sql, sql_exp *le, sql_exp *re, const char *compareop, int quantifier); #define exp_fromtype(e)((list*)e->r)->h->data #define exp_totype(e) ((list*)e->r)->h->next->data diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c
MonetDB: default - Merged with Jun2020
Changeset: 7265a00c77d1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7265a00c77d1 Modified Files: monetdb5/optimizer/opt_postfix.c Branch: default Log Message: Merged with Jun2020 diffs (54 lines): diff --git a/monetdb5/optimizer/opt_postfix.c b/monetdb5/optimizer/opt_postfix.c --- a/monetdb5/optimizer/opt_postfix.c +++ b/monetdb5/optimizer/opt_postfix.c @@ -32,27 +32,29 @@ OPTpostfixImplementation(Client cntxt, M for( i = 0; i< slimit; i++){ /* POSTFIX ACTION FOR THE JOIN CASE */ p= getInstrPtr(mb, i); - if ( getModuleId(p) == algebraRef && (getFunctionId(p) == joinRef - || getFunctionId(p) == leftjoinRef - || getFunctionId(p) == outerjoinRef - || getFunctionId(p) == thetajoinRef - || getFunctionId(p) == bandjoinRef - || getFunctionId(p) == rangejoinRef - || getFunctionId(p) == likejoinRef - || getFunctionId(p) == ilikejoinRef - || getFunctionId(p) == crossRef) && getVarEolife(mb, getArg(p, p->retc -1)) == i){ - delArgument(p, p->retc -1); - typeChecker(cntxt->usermodule, mb, p, i, TRUE); - actions++; - continue; - } - if ( getModuleId(p) == algebraRef && getFunctionId(p) == semijoinRef && getVarEolife(mb, getArg(p, p->retc -1)) == i){ - delArgument(p, p->retc -1); - /* semijoin with a single output is called intersect */ - setFunctionId(p,intersectRef); - typeChecker(cntxt->usermodule, mb, p, i, TRUE); - actions++; - continue; + if ( getModuleId(p) == algebraRef) { + if ( getFunctionId(p) == joinRef || getFunctionId(p) == leftjoinRef || getFunctionId(p) == outerjoinRef || +getFunctionId(p) == thetajoinRef || getFunctionId(p) == bandjoinRef || getFunctionId(p) == rangejoinRef || +getFunctionId(p) == likejoinRef || getFunctionId(p) == ilikejoinRef || getFunctionId(p) == crossRef) { + if ( getVarEolife(mb, getArg(p, p->retc -1)) == i) { + delArgument(p, p->retc -1); + typeChecker(cntxt->usermodule, mb, p, i, TRUE); + actions++; + continue; + } + } else if ( getFunctionId(p) == semijoinRef) { + int is_first_ret_not_used = getVarEolife(mb, getArg(p, p->retc -2)) == i; + int is_second_ret_not_used = getVarEolife(mb, getArg(p, p->retc -1)) == i; + assert(!is_first_ret_not_used || !is_second_ret_not_used); + if ( is_first_ret_not_used || is_second_ret_not_used) { + delArgument(p, is_second_ret_not_used ? p->retc -1 : p->retc -2); + /* semijoin with a single output is called intersect */ + setFunctionId(p,intersectRef); + typeChecker(cntxt->usermodule, mb, p, i, TRUE); + actions++; + continue; + } + } } /* POSTFIX ACTION FOR THE EXTENT CASE */ if ( getModuleId(p) == groupRef && getFunctionId(p) == groupRef && getVarEolife(mb, getArg(p, p->retc -1)) == i){ ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Merged with Jun2020
Changeset: 575a476e7027 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=575a476e7027 Modified Files: sql/backends/monet5/rel_bin.c sql/include/sql_catalog.h sql/rel.txt sql/server/rel_dump.c sql/server/rel_exp.c sql/server/rel_optimizer.c sql/test/subquery/Tests/subquery6.stable.err sql/test/subquery/Tests/subquery6.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 304 to 300 lines): 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 @@ -2192,7 +2192,7 @@ split_join_exps(sql_rel *rel, list *join int left_reference = 0, right_reference = 0; /* we can handle thetajoins, rangejoins and filter joins (like) */ - /* ToDo how about mark_exists/not_exists and atom expressions? */ + /* ToDo how about atom expressions? */ if (e->type == e_cmp) { int flag = e->flag & ~CMP_BETWEEN; /* check if its a select or join expression, ie use only expressions of one relation left and of the other right (than join) */ @@ -2200,17 +2200,32 @@ split_join_exps(sql_rel *rel, list *join /* join or select ? */ sql_exp *l = e->l, *r = e->r, *f = e->f; - if (l->card != CARD_ATOM) { - left_reference += rel_find_exp(rel->l, l) != NULL; - right_reference += rel_find_exp(rel->r, l) != NULL; - } - if (r->card != CARD_ATOM) { - left_reference += rel_find_exp(rel->l, r) != NULL; - right_reference += rel_find_exp(rel->r, r) != NULL; - } - if (f && f->card != CARD_ATOM) { - left_reference += rel_find_exp(rel->l, f) != NULL; - right_reference += rel_find_exp(rel->r, f) != NULL; + if (f) { + int ll = rel_find_exp(rel->l, l) != NULL; + int rl = rel_find_exp(rel->r, l) != NULL; + int lr = rel_find_exp(rel->l, r) != NULL; + int rr = rel_find_exp(rel->r, r) != NULL; + int lf = rel_find_exp(rel->l, f) != NULL; + int rf = rel_find_exp(rel->r, f) != NULL; + int nrcr1 = 0, nrcr2 = 0, nrcl1 = 0, nrcl2 = 0; + + if ((ll && !rl && + ((rr && !lr) || (nrcr1 = r->card == CARD_ATOM)) && + ((rf && !lf) || (nrcr2 = f->card == CARD_ATOM)) && (nrcr1+nrcr2) <= 1) || + (rl && !ll && + ((lr && !rr) || (nrcl1 = r->card == CARD_ATOM)) && + ((lf && !rf) || (nrcl2 = f->card == CARD_ATOM)) && (nrcl1+nrcl2) <= 1)) { + left_reference = right_reference = 1; + } + } else { + if (l->card != CARD_ATOM) { + left_reference += rel_find_exp(rel->l, l) != NULL; + right_reference += rel_find_exp(rel->r, l) != NULL; + } + if (r->card != CARD_ATOM) { + left_reference += rel_find_exp(rel->l, r) != NULL; + right_reference += rel_find_exp(rel->r, r) != NULL; + } } } else if (flag == cmp_filter) { list *l = e->l, *r = e->r; @@ -2242,7 +2257,7 @@ split_join_exps(sql_rel *rel, list *join } } -#define is_priority_exp(e) ((e)->type == e_cmp && (e)->flag == cmp_equal) +#define is_equi_exp(e) ((e)->flag == cmp_equal || (e)->flag == mark_in || (e)->flag
MonetDB: default - Merged with Jun2020
Changeset: 33d0aebde14c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=33d0aebde14c Modified Files: sql/backends/monet5/rel_bin.c sql/server/rel_optimizer.c sql/test/SQLancer/Tests/sqlancer01.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 589 to 300 lines): 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 @@ -2183,6 +2183,89 @@ releqjoin( backend *be, list *l1, list * return res; } +static void +split_join_exps(sql_rel *rel, list *joinable, list *not_joinable) +{ + if (!list_empty(rel->exps)) { + for (node *n = rel->exps->h; n; n = n->next) { + sql_exp *e = n->data; + int left_reference = 0, right_reference = 0; + + /* we can handle thetajoins, rangejoins and filter joins (like) */ + /* ToDo how about in/notin, mark_in/notin, mark_exists/not_exists and atom expressions? */ + if (e->type == e_cmp) { + int flag = e->flag & ~CMP_BETWEEN; + /* check if its a select or join expression, ie use only expressions of one relation left and of the other right (than join) */ + if (flag < cmp_filter) { /* theta and range joins */ + /* join or select ? */ + sql_exp *l = e->l, *r = e->r, *f = e->f; + + if (l->card != CARD_ATOM) { + left_reference += rel_find_exp(rel->l, l) != NULL; + right_reference += rel_find_exp(rel->r, l) != NULL; + } + if (r->card != CARD_ATOM) { + left_reference += rel_find_exp(rel->l, r) != NULL; + right_reference += rel_find_exp(rel->r, r) != NULL; + } + if (f && f->card != CARD_ATOM) { + left_reference += rel_find_exp(rel->l, f) != NULL; + right_reference += rel_find_exp(rel->r, f) != NULL; + } + } else if (flag == cmp_filter) { + list *l = e->l, *r = e->r; + + for (node *n = l->h ; n ; n = n->next) { + sql_exp *ee = n->data; + + if (ee->card != CARD_ATOM) { + left_reference += rel_find_exp(rel->l, ee) != NULL; + right_reference += rel_find_exp(rel->r, ee) != NULL; + } + } + for (node *n = r->h ; n ; n = n->next) { + sql_exp *ee = n->data; + + if (ee->card != CARD_ATOM) { + left_reference += rel_find_exp(rel->l, ee) != NULL; + right_reference += rel_find_exp(rel->r, ee) != NULL; + } + } + } + } + if (left_reference && right_reference) { + append(joinable, e); + } else { + append(not_joinable, e); + } + } + } +} + +#define is_priority_exp(e) ((e)->type == e_cmp && (e)->flag == cmp_equal) + +static list * +get_equi_joins_first(mvc *sql, list *exps, int *equality_only) +{ + list *new_exps = sa_list(sql->sa); + + for( node *n = exps->h; n; n = n->next ) { + sql_exp *e = n->data; + if (is_priority_exp(e)) { + list_append(new_exps, e); + *equality_only &= (e->flag == cmp_equal); + } + } + for( node *n = exps->h; n; n = n->next ) { + sql_exp *e = n->data; + if (!is_priority_exp(e)) { + list_append(new_exps, e); + *equality_only &= (e->flag == mark_in || e->flag == mark_notin); + } + } + return new_exps; +} + static stmt * rel2bin_join(backend *be, sql_rel *rel, list *refs) { @@ -2209,129 +2292,75 @@
MonetDB: default - Merged with Jun2020
Changeset: 436fdf28d606 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=436fdf28d606 Added Files: sql/test/json/Tests/jsonkeyarray.Bug-6858.stable.err sql/test/json/Tests/jsonkeyarray.Bug-6858.stable.out Modified Files: common/stream/stream.c geom/monetdb5/geom.c monetdb5/modules/atoms/json.c monetdb5/modules/kernel/batmmath.c monetdb5/modules/kernel/mmath.c sql/backends/monet5/sql.h sql/server/rel_optimizer.c sql/server/rel_select.c Branch: default Log Message: Merged with Jun2020 diffs (239 lines): diff --git a/common/stream/stream.c b/common/stream/stream.c --- a/common/stream/stream.c +++ b/common/stream/stream.c @@ -2187,7 +2187,7 @@ write_callback(char *buffer, size_t size size_t maxsize; maxsize = (c->usesize + size + BLOCK_CURL - 1) & ~(BLOCK_CURL - 1); - b = realloc(c->buffer, c->maxsize); + b = realloc(c->buffer, maxsize); if (b == NULL) return 0; /* indicate failure to library */ c->buffer = b; diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c --- a/geom/monetdb5/geom.c +++ b/geom/monetdb5/geom.c @@ -50,18 +50,20 @@ wkbNULLcopy(void) static inline void degrees2radians(double *x, double *y, double *z) { - *x *= M_PI / 180.0; - *y *= M_PI / 180.0; - *z *= M_PI / 180.0; + double val = M_PI / 180.0; + *x *= val; + *y *= val; + *z *= val; } /** convert radians to degrees */ static inline void radians2degrees(double *x, double *y, double *z) { - *x *= 180.0 / M_PI; - *y *= 180.0 / M_PI; - *z *= 180.0 / M_PI; + double val = 180.0 / M_PI; + *x *= val; + *y *= val; + *z *= val; } static str diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c --- a/monetdb5/modules/atoms/json.c +++ b/monetdb5/modules/atoms/json.c @@ -1554,6 +1554,13 @@ JSONkeyArray(json *ret, json *js) } if (jt->elm[i].valuelen) strncpy(r, jt->elm[i].value - 1, jt->elm[i].valuelen + 2); + else { + r = GDKstrdup("\"\""); + if(r == NULL) { + JSONfree(jt); + goto memfail; + } + } result = JSONglue(result, r, ','); if (result == NULL) { JSONfree(jt); 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 @@ -450,25 +450,25 @@ CMDscience_bat_##FUNC(Client cntxt, MalB static double radians(double x) { - return x * 3.14159265358979323846 / 180.0; + return x * (3.14159265358979323846 / 180.0); } static float radiansf(float x) { - return (float) (x * 3.14159265358979323846 / 180.0); + return (float) (x * (3.14159265358979323846 / 180.0)); } static double degrees(double x) { - return x * 180.0 / 3.14159265358979323846; + return x * (180.0 / 3.14159265358979323846); } static float degreesf(float x) { - return (float) (x * 180.0 / 3.14159265358979323846); + return (float) (x * (180.0 / 3.14159265358979323846)); } mal_export str CMDscience_bat_asin(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); diff --git a/monetdb5/modules/kernel/mmath.c b/monetdb5/modules/kernel/mmath.c --- a/monetdb5/modules/kernel/mmath.c +++ b/monetdb5/modules/kernel/mmath.c @@ -32,8 +32,8 @@ #endif #define cot(x) (1 / tan(x)) -#define radians(x) ((x) * 3.14159265358979323846 / 180.0) -#define degrees(x) ((x) * 180.0 / 3.14159265358979323846) +#define radians(x) ((x) * (3.14159265358979323846 / 180.0)) +#define degrees(x) ((x) * (180.0 / 3.14159265358979323846)) double logbs(double x, double base) diff --git a/sql/backends/monet5/sql.h b/sql/backends/monet5/sql.h --- a/sql/backends/monet5/sql.h +++ b/sql/backends/monet5/sql.h @@ -269,8 +269,8 @@ sql5_export str dbl_round_wrap(dbl *res, sql5_export str dbl_bat_round_wrap(bat *res, const bat *v, const bte *r); sql5_export str dbl_trunc_wrap(dbl *res, const dbl *v, const int *r); -#define radians(x) ((x) * 3.14159265358979323846 /180.0 ) -#define degrees(x) ((x) * 180.0/3.14159265358979323846 ) +#define radians(x) ((x) * (3.14159265358979323846 / 180.0)) +#define degrees(x) ((x) * (180.0 / 3.14159265358979323846)) sql5_export str SQLcst_alpha_cst(dbl *res, const dbl *decl, const dbl *theta); sql5_export str SQLbat_alpha_cst(bat *res, const bat *decl, const dbl *theta); diff --git
MonetDB: default - Merged with Jun2020
Changeset: a9b1470c96fd for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a9b1470c96fd Modified Files: sql/server/rel_optimizer.c sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out.int128 Branch: default Log Message: Merged with Jun2020 diffs (74 lines): diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -3764,7 +3764,7 @@ rel_project_cse(mvc *sql, sql_rel *rel, for (m=nexps->h; m; m = m->next){ sql_exp *e2 = m->data; - if (exp_name(e2) && exp_match_exp(e1, e2) && exps_bind_column2(nexps, exp_relname(e1), exp_name(e1)) == e1) { + if (exp_name(e2) && exp_match_exp(e1, e2) && (e1->type != e_column || exps_bind_column2(nexps, exp_relname(e1), exp_name(e1)) == e1)) { sql_exp *ne = exp_alias(sql->sa, exp_relname(e1), exp_name(e1), exp_relname(e2), exp_name(e2), exp_subtype(e2), e2->card, has_nil(e2), is_intern(e1)); ne = exp_propagate(sql->sa, ne, e1); diff --git a/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out b/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out --- a/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out +++ b/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out @@ -29,11 +29,11 @@ stdout of test 'crash_on_alias.Bug-2798` % .plan # table_name % rel # name % clob # type -% 114 # length +% 103 # length project ( | group by ( | | table(sys.dbg) [ "dbg"."a", "dbg"."b" ] COUNT -| ) [ "dbg"."a" as "d" ] [ "d", sys.sum no nil ("dbg"."b") as "%1"."%1", sys.sum no nil ("dbg"."b") as "%2"."%2" ] +| ) [ "dbg"."a" as "d" ] [ "d", sys.sum no nil ("dbg"."b") as "%1"."%1", "%1"."%1" as "%2"."%2" ] ) [ "d", "%1"."%1", sys.sql_mul(sys.sql_div("%2"."%2", tinyint "2" as "%3"."%3"), tinyint "2") as "f" ] #set optimizer = 'sequential_pipe'; #set optimizer = 'default_pipe'; @@ -53,11 +53,11 @@ project ( % .plan # table_name % rel # name % clob # type -% 114 # length +% 110 # length project ( | group by ( | | table(sys.dbg) [ "dbg"."a", "dbg"."b" ] COUNT -| ) [ "dbg"."a" as "d" ] [ "d", sys.sum no nil ("dbg"."b") as "%1"."%1", sys.sum no nil ("dbg"."b") as "%2"."%2" ] +| ) [ "dbg"."a" as "d" ] [ "d", sys.sum no nil ("dbg"."b") as "%1"."%1", "%1"."%1" as "%2"."%2" ] ) [ "d", "%1"."%1" as "e", sys.sql_mul(sys.sql_div("%2"."%2", tinyint "2" as "%3"."%3"), tinyint "2") as "f" ] #set optimizer = 'sequential_pipe'; #set optimizer = 'default_pipe'; diff --git a/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out.int128 b/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out.int128 --- a/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out.int128 +++ b/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out.int128 @@ -29,11 +29,11 @@ stdout of test 'crash_on_alias.Bug-2798` % .plan # table_name % rel # name % clob # type -% 114 # length +% 103 # length project ( | group by ( | | table(sys.dbg) [ "dbg"."a", "dbg"."b" ] COUNT -| ) [ "dbg"."a" as "d" ] [ "d", sys.sum no nil ("dbg"."b") as "%1"."%1", sys.sum no nil ("dbg"."b") as "%2"."%2" ] +| ) [ "dbg"."a" as "d" ] [ "d", sys.sum no nil ("dbg"."b") as "%1"."%1", "%1"."%1" as "%2"."%2" ] ) [ "d", "%1"."%1", sys.sql_mul(sys.sql_div("%2"."%2", tinyint "2" as "%3"."%3"), tinyint "2") as "f" ] #set optimizer = 'sequential_pipe'; #set optimizer = 'default_pipe'; @@ -53,11 +53,11 @@ project ( % .plan # table_name % rel # name % clob # type -% 114 # length +% 110 # length project ( | group by ( | | table(sys.dbg) [ "dbg"."a", "dbg"."b" ] COUNT -| ) [ "dbg"."a" as "d" ] [ "d", sys.sum no nil ("dbg"."b") as "%1"."%1", sys.sum no nil ("dbg"."b") as "%2"."%2" ] +| ) [ "dbg"."a" as "d" ] [ "d", sys.sum no nil ("dbg"."b") as "%1"."%1", "%1"."%1" as "%2"."%2" ] ) [ "d", "%1"."%1" as "e", sys.sql_mul(sys.sql_div("%2"."%2", tinyint "2" as "%3"."%3"), tinyint "2") as "f" ] #set optimizer = 'sequential_pipe'; #set optimizer = 'default_pipe'; ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Merged with Jun2020
Changeset: 017580f64a06 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=017580f64a06 Added Files: sql/test/miscellaneous/Tests/simple_plans.stable.out.single Modified Files: sql/server/rel_exp.c sql/server/rel_optimizer.c sql/server/rel_unnest.c sql/test/BugTracker-2018/Tests/sqlitelogictest-cast-null-add.Bug-6630.stable.out sql/test/BugTracker-2018/Tests/sqlitelogictest-groupby-having-in.Bug-6560.stable.out sql/test/BugTracker-2020/Tests/select-and.Bug-6878.stable.out sql/test/SQLancer/Tests/sqlancer01.sql sql/test/SQLancer/Tests/sqlancer01.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 985 to 300 lines): diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c --- a/sql/server/rel_exp.c +++ b/sql/server/rel_exp.c @@ -2186,7 +2186,7 @@ exp_unsafe( sql_exp *e, int allow_identi if (e->type == e_convert && e->l) return exp_unsafe(e->l, allow_identity); - if (e->type == e_func && e->l) { + if ((e->type == e_func || e->type == e_aggr) && e->l) { sql_subfunc *f = e->f; list *args = e->l; node *n; diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -1325,22 +1325,8 @@ exp_rename(mvc *sql, sql_exp *e, sql_rel } static int -math_unsafe(sql_subfunc *f) -{ - if (!f->func->s) { - if (strcmp(f->func->base.name, "sql_div") == 0 || - strcmp(f->func->base.name, "sqrt") == 0 || - strcmp(f->func->base.name, "atan") == 0 ) - return 1; - } - return 0; -} - -static int can_push_func(sql_exp *e, sql_rel *rel, int *must) { - if (!e) - return 0; switch(e->type) { case e_cmp: { int mustl = 0, mustr = 0, mustf = 0; @@ -1349,24 +1335,21 @@ can_push_func(sql_exp *e, sql_rel *rel, if (e->flag == cmp_or || e->flag == cmp_in || e->flag == cmp_notin || e->flag == cmp_filter) return 0; return ((l->type == e_column || can_push_func(l, rel, )) && (*must = mustl)) || - (!f && (r->type == e_column || can_push_func(r, rel, )) && (*must = mustr)) || - (f && - (r->type == e_column || can_push_func(r, rel, )) && - (f->type == e_column || can_push_func(f, rel, )) && (*must = (mustr || mustf))); + (!f && (r->type == e_column || can_push_func(r, rel, )) && (*must = mustr)) || + (f && + (r->type == e_column || can_push_func(r, rel, )) && + (f->type == e_column || can_push_func(f, rel, )) && (*must = (mustr || mustf))); } case e_convert: return can_push_func(e->l, rel, must); + case e_aggr: case e_func: { list *l = e->l; - node *n; int res = 1, lmust = 0; - - if (e->f){ - sql_subfunc *f = e->f; - if (math_unsafe(f) || f->func->type != F_FUNC) - return 0; - } - if (l) for (n = l->h; n && res; n = n->next) + + if (exp_unsafe(e, 0)) + return 0; + if (l) for (node *n = l->h; n && res; n = n->next) res &= can_push_func(n->data, rel, ); if (res && !lmust) return 1; @@ -1378,7 +1361,6 @@ can_push_func(sql_exp *e, sql_rel *rel, return 0; (*must) = 1; /* fall through */ - case e_atom: default: return 1; } @@ -1387,15 +1369,13 @@ can_push_func(sql_exp *e, sql_rel *rel, static int exps_can_push_func(list *exps, sql_rel *rel) { - node *n; - - for(n = exps->h; n; n = n->next) { + for(node *n = exps->h; n; n = n->next) { sql_exp *e = n->data; int must = 0, mustl = 0, mustr = 0; if (is_joinop(rel->op) && ((can_push_func(e, rel->l, ) && mustl) || (can_push_func(e, rel->r, ) && mustr))) return 1; - else if (is_select(rel->op) && can_push_func(e, NULL, ) && must) + else if (is_select(rel->op) && can_push_func(e, rel->l, ) && must) return 1; } return 0; @@ -1404,8 +1384,6 @@ exps_can_push_func(list *exps, sql_rel * static int exp_needs_push_down(sql_exp *e) { - if (!e) - return 0; switch(e->type) { case e_cmp: if (e->flag == cmp_or || e->flag == cmp_in || e->flag == cmp_notin || e->flag == cmp_filter) @@ -1413,8
MonetDB: default - Merged with Jun2020
Changeset: 9dbc91b83efa for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9dbc91b83efa Modified Files: gdk/gdk_hash.c monetdb5/modules/atoms/uuid.c sql/backends/monet5/rel_bin.c sql/server/rel_exp.c sql/server/rel_exp.h sql/server/rel_optimizer.c sql/server/rel_select.c sql/test/BugTracker-2008/Tests/decimal_cast_in_view.SF-2075223.stable.out sql/test/BugTracker-2014/Tests/missing_alias.Bug-3626.stable.out sql/test/BugTracker-2015/Tests/string-to-inet.Bug-3666.stable.out sql/test/BugTracker-2016/Tests/convert-function-test-hge.Bug-3460.stable.out.int128 sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.stable.out sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.stable.out.int128 sql/test/BugTracker-2018/Tests/convert-key.Bug-6648.stable.out sql/test/BugTracker-2019/Tests/cast-interval.Bug-6793.stable.out sql/test/BugTracker/Tests/convert_dec2varchar.SF-1774312.stable.out sql/test/BugTracker/Tests/jdbc_no_debug.SF-1739356.stable.out sql/test/SQLancer/Tests/sqlancer01.sql sql/test/SQLancer/Tests/sqlancer01.stable.err sql/test/SQLancer/Tests/sqlancer01.stable.out sql/test/bugs/Tests/cast_varchar2int-bug-sf-964165.stable.out sql/test/mergetables/Tests/mergeinit.stable.err sql/test/miscellaneous/Tests/groupings.stable.out sql/test/miscellaneous/Tests/simple_plans.sql sql/test/miscellaneous/Tests/simple_plans.stable.out sql/test/miscellaneous/Tests/simple_selects.stable.out sql/test/pg_regress/Tests/date.stable.out sql/test/pg_regress/Tests/int8.stable.out sql/test/pg_regress/Tests/int8.stable.out.int128 Branch: default Log Message: Merged with Jun2020 diffs (truncated from 13199 to 300 lines): diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c --- a/gdk/gdk_hash.c +++ b/gdk/gdk_hash.c @@ -97,7 +97,11 @@ HASHclear(Hash *h) memset(h->Bckt, 0xFF, h->nbucket * h->width); } -#define HASH_VERSION 3 +#define HASH_VERSION 4 +/* this is only for the change of hash function of the UUID type; if + * HASH_VERSION is increased again from 4, the code associated with + * HASH_VERSION_NOUUID must be deleted */ +#define HASH_VERSION_NOUUID3 #define HASH_HEADER_SIZE 7 /* nr of size_t fields in header */ static void @@ -442,11 +446,21 @@ BATcheckhash(BAT *b) struct stat st; if (read(fd, hdata, sizeof(hdata)) == sizeof(hdata) && - hdata[0] == ( + (hdata[0] == ( #ifdef PERSISTENTHASH ((size_t) 1 << 24) | #endif - HASH_VERSION) && + HASH_VERSION) +#ifdef HASH_VERSION_NOUUID +/* if not uuid, also allow previous version */ +|| (hdata[0] == ( +#ifdef PERSISTENTHASH +((size_t) 1 << 24) | +#endif +HASH_VERSION_NOUUID) && +strcmp(ATOMname(b->ttype), "uuid") != 0) +#endif + ) && hdata[1] > 0 && hdata[4] == (size_t) BATcount(b) && fstat(fd, ) == 0 && 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 @@ -330,17 +330,19 @@ BUN UUIDhash(const void *v) { const uuid *u = (const uuid *) v; - unsigned int u1, u2, u3, u4; + ulng u1, u2; - u1 = (unsigned int) u->u[0] << 24 | (unsigned int) u->u[1] << 16 | - (unsigned int) u->u[2] << 8 | (unsigned int) u->u[3]; - u2 = (unsigned int) u->u[4] << 24 | (unsigned int) u->u[5] << 16 | - (unsigned int) u->u[6] << 8 | (unsigned int) u->u[7]; - u3 = (unsigned int) u->u[8] << 24 | (unsigned int) u->u[9] << 16 | - (unsigned int) u->u[10] << 8 | (unsigned int) u->u[11]; - u4 = (unsigned int) u->u[12] << 24 | (unsigned int) u->u[13] << 16 | - (unsigned int) u->u[14] << 8 | (unsigned int) u->u[15]; - return (BUN) mix_int(u1 ^ u2 ^ u3 ^ u4); + u1 = (ulng) u->u[0] << 56 | (ulng) u->u[1] << 48 | + (ulng) u->u[2] << 40 | (ulng) u->u[3] << 32 | + (ulng) u->u[4] << 24 | (ulng) u->u[5] << 16 | + (ulng) u->u[6] << 8 | (ulng) u->u[7]; + u2 = (ulng) u->u[8] << 56 | (ulng) u->u[9] << 48 | +
MonetDB: default - Merged with Jun2020
Changeset: 8a4c4fdeaef8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8a4c4fdeaef8 Added Files: sql/test/BugTracker-2020/Tests/url-nulls.Bug-6845.sql sql/test/BugTracker-2020/Tests/url-nulls.Bug-6845.stable.err sql/test/BugTracker-2020/Tests/url-nulls.Bug-6845.stable.out Modified Files: monetdb5/modules/atoms/url.c sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_statement.c sql/server/sql_atom.c sql/server/sql_atom.h sql/test/BugDay_2005-10-06_2.9.3/Tests/UNION_JOIN_vs_plain_set_UNION-2.SF-920585.stable.out sql/test/BugTracker-2020/Tests/All sql/test/SQLancer/Tests/sqlancer01.sql sql/test/SQLancer/Tests/sqlancer01.stable.out sql/test/pg_regress/Tests/strings.stable.out sql/test/pg_regress/Tests/strings_cast.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 863 to 300 lines): diff --git a/monetdb5/modules/atoms/url.c b/monetdb5/modules/atoms/url.c --- a/monetdb5/modules/atoms/url.c +++ b/monetdb5/modules/atoms/url.c @@ -339,15 +339,21 @@ URLgetAnchor(str *retval, url *val) if (val == NULL || *val == NULL) throw(ILLARG, "url.getAnchor", "url missing"); - if ((s = skip_scheme(*val)) == NULL || - (s = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || - (s = skip_path(s, NULL, NULL)) == NULL || - (s = skip_search(s)) == NULL) - throw(ILLARG, "url.getAnchor", "bad url"); - if (*s == '#') - s++; - else + + if (strNil(*val)) { s = str_nil; + } else { + if ((s = skip_scheme(*val)) == NULL || + (s = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || + (s = skip_path(s, NULL, NULL)) == NULL || + (s = skip_search(s)) == NULL) + throw(ILLARG, "url.getAnchor", "bad url"); + if (*s == '#') + s++; + else + s = str_nil; + } + if ((*retval = GDKstrdup(s)) == NULL) throw(MAL, "url.getAnchor", SQLSTATE(HY013) MAL_MALLOC_FAIL); return MAL_SUCCEED; @@ -365,24 +371,30 @@ URLgetBasename(str *retval, url *val) if (val == NULL || *val == NULL) throw(ILLARG, "url.getBasename", "url missing"); - if ((s = skip_scheme(*val)) == NULL || - (s = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || - (s = skip_path(s, , )) == NULL) - throw(ILLARG, "url.getBasename", "bad url"); - if (b == NULL) { + + if (strNil(*val)) { *retval = GDKstrdup(str_nil); } else { - size_t l; - - if (e != NULL) { - l = e - b; + if ((s = skip_scheme(*val)) == NULL || + (s = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || + (s = skip_path(s, , )) == NULL) + throw(ILLARG, "url.getBasename", "bad url"); + if (b == NULL) { + *retval = GDKstrdup(str_nil); } else { - l = s - b; - } - if ((*retval = GDKmalloc(l + 1)) != NULL) { - strcpy_len(*retval, b, l + 1); + size_t l; + + if (e != NULL) { + l = e - b; + } else { + l = s - b; + } + if ((*retval = GDKmalloc(l + 1)) != NULL) { + strcpy_len(*retval, b, l + 1); + } } } + if (*retval == NULL) throw(MAL, "url.getBasename", SQLSTATE(HY013) MAL_MALLOC_FAIL); return MAL_SUCCEED; @@ -398,15 +410,21 @@ URLgetContext(str *retval, url *val) if (val == NULL || *val == NULL) throw(ILLARG, "url.getContext", "url missing"); - if ((s = skip_scheme(*val)) == NULL || - (p = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || - (s = skip_path(p, NULL, NULL)) == NULL) - throw(ILLARG, "url.getContext", "bad url"); - if (p == s) { + + if (strNil(*val)) { *retval = GDKstrdup(str_nil); - } else if ((*retval = GDKmalloc(s - p + 1)) != NULL) { - strcpy_len(*retval, p, s - p + 1); + } else { + if ((s = skip_scheme(*val)) == NULL || + (p = skip_authority(s, NULL, NULL, NULL, NULL)) == NULL || + (s = skip_path(p, NULL, NULL)) == NULL) + throw(ILLARG, "url.getContext", "bad url"); + if (p == s) { + *retval = GDKstrdup(str_nil); +
MonetDB: default - Merged with Jun2020
Changeset: 65a67c23c2c1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=65a67c23c2c1 Added Files: sql/test/BugTracker-2020/Tests/url-getuser.Bug-6844.sql sql/test/BugTracker-2020/Tests/url-getuser.Bug-6844.stable.err sql/test/BugTracker-2020/Tests/url-getuser.Bug-6844.stable.out sql/test/json/Tests/jsonkeyarray.Bug-6858.sql sql/test/json/Tests/jsontext.Bug-6859.sql Modified Files: monetdb5/modules/atoms/url.c sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_round_impl.h sql/server/rel_optimizer.c sql/server/sql_parser.y sql/test/BugTracker-2012/Tests/url_script_test.Bug-2972.stable.out sql/test/BugTracker-2020/Tests/All sql/test/SQLancer/Tests/SingleServer sql/test/SQLancer/Tests/sqlancer01.sql sql/test/SQLancer/Tests/sqlancer01.stable.err sql/test/SQLancer/Tests/sqlancer01.stable.out sql/test/json/Tests/All Branch: default Log Message: Merged with Jun2020 diffs (truncated from 612 to 300 lines): diff --git a/monetdb5/modules/atoms/url.c b/monetdb5/modules/atoms/url.c --- a/monetdb5/modules/atoms/url.c +++ b/monetdb5/modules/atoms/url.c @@ -637,25 +637,31 @@ URLgetRobotURL(str *retval, url *val) return MAL_SUCCEED; } - /* COMMAND "getUser": Extract the user identity from the URL * SIGNATURE: getUser(str) : str; */ str URLgetUser(str *retval, url *val) { - const char *s; - const char *p; - const char *u; + const char *s, *h, *u, *p; if (val == NULL || *val == NULL) throw(ILLARG, "url.getUser", "url missing"); if ((s = skip_scheme(*val)) == NULL || - (p = skip_authority(s, , NULL, NULL, NULL)) == NULL) - throw(ILLARG, "url.getUser", "bad url"); - if (u == s || !u) { + (s = skip_authority(s, , , , NULL)) == NULL) + throw(ILLARG, "url.getHost", "bad url"); + if (u == NULL || h == NULL) { *retval = GDKstrdup(str_nil); } else { - *retval = GDKstrdup(u); + size_t l; + + if (p) { + l = p - u - 1; + } else { + l = h - u - 1; + } + if ((*retval = GDKmalloc(l + 1)) != NULL) { + strcpy_len(*retval, u, l + 1); + } } if (*retval == NULL) throw(MAL, "url.getUser", SQLSTATE(HY013) MAL_MALLOC_FAIL); 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 @@ -,11 +,14 @@ exp_bin(backend *be, sql_exp *e, stmt *l } } else { /* value compare or select */ - if (!reduce || (l->nrcols == 0 && r->nrcols == 0 && (e->flag == mark_in || e->flag == mark_notin))) { - sql_subfunc *f = sql_bind_func(sql->sa, sql->session->schema, "=", tail_type(l), tail_type(l), F_FUNC); + if ((!reduce || (l->nrcols == 0 && r->nrcols == 0)) && (e->flag == mark_in || e->flag == mark_notin)) { + int in_flag = e->flag==mark_in?1:0; + if (e->anti) + in_flag = !in_flag; + sql_subfunc *f = sql_bind_func(sql->sa, sql->session->schema, in_flag?"=":"<>", tail_type(l), tail_type(l), F_FUNC); assert(f); s = stmt_binop(be, l, r, f); - } else if (l->nrcols == 0 && r->nrcols == 0) { + } else if (!reduce || (l->nrcols == 0 && r->nrcols == 0)) { sql_subfunc *f = sql_bind_func(sql->sa, sql->session->schema, compare_func((comp_type)e->flag, is_anti(e)), tail_type(l), tail_type(l), F_FUNC); @@ -2218,8 +2221,8 @@ rel2bin_join(backend *be, sql_rel *rel, sql_exp *e = en->data; /* we can handle thetajoins, rangejoins and filter joins (like) */ - /* ToDo how about in/notin, mark_in/notin, mark_exists/not_exists */ - if (e->type <= e_cmp) { + /* ToDo how about in/notin, mark_in/notin, mark_exists/not_exists and atom expressions? */ + if (e->type == e_cmp) { int flag = e->flag & ~CMP_BETWEEN; /* check if its a select or join expression, ie use only expressions
MonetDB: default - Merged with Jun2020 carefully
Changeset: d3a40c829f76 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d3a40c829f76 Modified Files: gdk/gdk_utils.c sql/backends/monet5/rel_bin.c sql/test/subquery/Tests/subquery6.sql sql/test/subquery/Tests/subquery6.stable.out Branch: default Log Message: Merged with Jun2020 carefully diffs (168 lines): diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c --- a/gdk/gdk_utils.c +++ b/gdk/gdk_utils.c @@ -413,7 +413,7 @@ MT_init(void) cgr = cgr2; else continue; - /* buf point at mount ID */ + /* buf points at mount ID */ p = strchr(buf, ' '); if (p == NULL) break; @@ -469,13 +469,14 @@ MT_init(void) bool success = false; /* true if we can open any file */ FILE *f; uint64_t mem; - size_t l; p = strchr(buf, '\n'); if (p == NULL) break; *p = 0; if (strncmp(buf, "0::", 3) == 0) { + size_t l; + /* cgroup v2 entry */ l = strconcat_len(pth, sizeof(pth), cgr2, buf + 3, "/", NULL); @@ -525,11 +526,19 @@ MT_init(void) *p++ = 0; if (strstr(q, "memory") == NULL) continue; - l = strconcat_len(pth, sizeof(pth), - cgr1, p, "/", NULL); /* limit of memory usage */ - strcpy(pth + l, "memory.limit_in_bytes"); + strconcat_len(pth, sizeof(pth), + cgr1, p, + "/memory.limit_in_bytes", + NULL); f = fopen(pth, "r"); + if (f == NULL) { + strconcat_len(pth, sizeof(pth), + cgr1, + "/memory.limit_in_bytes", + NULL); + f = fopen(pth, "r"); + } if (f != NULL) { if (fscanf(f, "%" SCNu64, ) == 1 && mem < (uint64_t) _MT_pagesize * _MT_npages) { @@ -539,8 +548,18 @@ MT_init(void) fclose(f); } /* soft limit of memory usage */ - strcpy(pth + l, "memory.soft_limit_in_bytes"); + strconcat_len(pth, sizeof(pth), + cgr1, p, + "/memory.soft_limit_in_bytes", + NULL); f = fopen(pth, "r"); + if (f == NULL) { + strconcat_len(pth, sizeof(pth), + cgr1, + "/memory.soft_limit_in_bytes", + NULL); + f = fopen(pth, "r"); + } if (f != NULL) { if (fscanf(f, "%" SCNu64, ) == 1 && mem < (uint64_t) _MT_pagesize * _MT_npages) { @@ -551,8 +570,18 @@ MT_init(void) } /* limit of memory+swap usage * we use this as maximum virtual memory size */ - strcpy(pth + l, "memory.memsw.limit_in_bytes"); + strconcat_len(pth, sizeof(pth), + cgr1, p, + "/memory.memsw.limit_in_bytes", + NULL); f = fopen(pth, "r"); + if (f == NULL) { + strconcat_len(pth, sizeof(pth), + cgr1, + "/memory.memsw.limit_in_bytes", +
MonetDB: default - Merged with Jun2020
Changeset: 17838718818a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=17838718818a Modified Files: sql/backends/monet5/rel_bin.c Branch: default Log Message: Merged with Jun2020 diffs (63 lines): 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 @@ -,7 +,7 @@ rel2bin_join(backend *be, sql_rel *rel, if (e->type <= e_cmp) { int flag = e->flag & ~CMP_BETWEEN; /* check if its a select or join expression, ie use only expressions of one relation left and of the other right (than join) */ - if (flag <= cmp_filter && !e->f) { /* theta join */ + if (flag < cmp_filter && !e->f) { /* theta join */ /* join or select ? */ if ((rel_find_exp(rel->l, e->l) && !rel_find_exp(rel->r, e->l) && rel_find_exp(rel->r, e->r) && !rel_find_exp(rel->l, e->r)) || @@ -2231,7 +2231,7 @@ rel2bin_join(backend *be, sql_rel *rel, append(jexps, e); continue; } - } else if (flag <= cmp_filter && e->f) { /* range */ + } else if (flag < cmp_filter && e->f) { /* range */ int nrcr1 = 0, nrcr2 = 0, nrcl1 = 0, nrcl2 = 0; if ((rel_find_exp(rel->l, e->l) && !rel_find_exp(rel->r, e->l) && ((rel_find_exp(rel->r, e->r) && !rel_find_exp(rel->l, e->r)) || (nrcr1 = exp_is_atom(e->r))) && @@ -2315,36 +2315,13 @@ rel2bin_join(backend *be, sql_rel *rel, } if (join_idx != sql->opt_stats[0]) idx = 1; - - if (s->type != st_join && - s->type != st_join2 && - s->type != st_joinN) { - assert(0); - - /* predicate */ - if (!list_length(lje) && s->nrcols == 0) { - assert(0); - stmt *l = bin_first_column(be, left); - stmt *r = bin_first_column(be, right); - - l = stmt_uselect(be, stmt_const(be, l, stmt_bool(be, 1)), s, cmp_equal, NULL, 0, 0); - join = stmt_join(be, l, r, 0, cmp_all, 0, false); - continue; - } - if (!join) { - assert(0); - stmt *l = bin_first_column(be, left); - stmt *r = bin_first_column(be, right); - join = stmt_join(be, l, r, 0, cmp_all, 0, false); - en = rel->exps->h; - } + assert(s->type == st_join || s->type == st_join2 || s->type == st_joinN); + if (!join) + join = s; + if (e->flag != cmp_equal) { /* only collect equi joins */ + en = en->next; break; } - - if (!join) - join = s; - if (e->flag != cmp_equal) /* only collect equi joins */ - break; list_append(lje, s->op1); list_append(rje, s->op2); list_append(exps, e); ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Merged with Jun2020
Changeset: df306dae87dd for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=df306dae87dd Modified Files: gdk/gdk_select.c monetdb5/modules/atoms/str.c monetdb5/modules/mal/pcre.c monetdb5/modules/mal/tablet.c monetdb5/optimizer/opt_mergetable.c sql/backends/monet5/rel_bin.c sql/test/SQLancer/Tests/sqlancer01.sql sql/test/SQLancer/Tests/sqlancer01.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 880 to 300 lines): diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -2243,16 +2243,12 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT ro = canditer_next(rci); if (rlvals) { vrl = VALUE(rl, ro - rl->hseqbase); - if (cmp(vrl, nil) == 0) - continue; } else { /* TYPE_void */ rlval = ro - rl->hseqbase + rl->tseqbase; } if (rhvals) { vrh = VALUE(rh, ro - rh->hseqbase); - if (cmp(vrh, nil) == 0) - continue; } else { /* TYPE_void */ rhval = ro - rh->hseqbase + rh->tseqbase; diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c --- a/monetdb5/modules/atoms/str.c +++ b/monetdb5/modules/atoms/str.c @@ -4133,7 +4133,7 @@ STRinsert(str *ret, const str *s, const if (l1 + l2 + 1 >= INT_MAX) throw(MAL, "str.insert", SQLSTATE(HY013) MAL_MALLOC_FAIL); if (*l < 0) - throw(MAL, "str.insert", SQLSTATE(42000) ILLEGAL_ARGUMENT); + throw(MAL, "str.insert", SQLSTATE(42000) "The number of characters for insert function must be non negative"); if (strt < 0) { if ((size_t) -strt <= l1) strt = (int) (l1 + strt); diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c --- a/monetdb5/modules/mal/pcre.c +++ b/monetdb5/modules/mal/pcre.c @@ -361,7 +361,7 @@ mywstrcasestr(const char *restrict hayst /* returns true if the pattern does not contain unescaped `_' (single * character match) and ends with unescaped `%' (any sequence * match) */ -static bool +static inline bool re_simple(const char *pat, unsigned char esc) { bool escaped = false; @@ -384,7 +384,7 @@ re_simple(const char *pat, unsigned char return true; } -static bool +static inline bool re_is_pattern_properly_escaped(const char *pat, unsigned char esc) { bool escaped = false; @@ -1738,8 +1738,8 @@ PCREsql2pcre(str *ret, const str *pat, c return sql2pcre(ret, *pat, *esc); } -static str -choose_like_path(char **ppat, bool *use_re, bool *use_strcmp, bool *empty, const str *pat, const str *esc, const bit *caseignore) +static inline str +choose_like_path(char **ppat, bool *use_re, bool *use_strcmp, bool *empty, const str *pat, const str *esc) { str res = MAL_SUCCEED; *use_re = false; @@ -1762,11 +1762,8 @@ choose_like_path(char **ppat, bool *use_ if (strNil(*ppat)) { GDKfree(*ppat); *ppat = NULL; - if (*caseignore) { - if (!(*ppat = GDKmalloc(strlen(*pat) + 3))) - throw(MAL, "algebra.likeselect", SQLSTATE(HY013) MAL_MALLOC_FAIL); - stpcpy(stpcpy(stpcpy(*ppat, "^"), *pat), "$"); - } + *use_re = true; + *use_strcmp = true; } } } @@ -1779,46 +1776,28 @@ PCRElike4(bit *ret, const str *s, const str res = MAL_SUCCEED; char *ppat = NULL; bool use_re = false, use_strcmp = false, isnull = false; - uint32_t *wpat = NULL; struct RE *re = NULL; - if ((res = choose_like_path(, _re, _strcmp, , pat, esc, isens)) != MAL_SUCCEED) + if ((res = choose_like_path(, _re, _strcmp, , pat, esc)) != MAL_SUCCEED) return res; - if (strNil(*s)) { + if (strNil(*s) || isnull) { *ret = bit_nil; } else if (use_re) { if (use_strcmp) { - if (*isens) { - if (!(wpat = utf8stoucs(*pat))) { - res = createException(MAL,
MonetDB: default - Merged with Jun2020
Changeset: bf9ff264d592 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bf9ff264d592 Modified Files: monetdb5/modules/atoms/str.c sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_statement.c sql/test/SQLancer/Tests/SingleServer sql/test/SQLancer/Tests/sqlancer01.sql sql/test/SQLancer/Tests/sqlancer01.stable.out Branch: default Log Message: Merged with Jun2020 diffs (186 lines): diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c --- a/monetdb5/modules/atoms/str.c +++ b/monetdb5/modules/atoms/str.c @@ -3745,10 +3745,10 @@ STRRtrim(str *res, const str *arg1) /* return a list of codepoints in s */ static int * -trimchars(const char *s, size_t *n) +trimchars(const char *s, size_t *n, size_t len_s) { size_t len = 0; - int *chars = GDKmalloc(strlen(s) * sizeof(int)); + int *chars = GDKmalloc(len_s * sizeof(int)); int c; if (chars == NULL) @@ -3772,15 +3772,15 @@ str STRStrip2(str *res, const str *arg1, const str *arg2) { const char *s = *arg1; - size_t len; - size_t n; - size_t nchars; + size_t len, n, nchars, n2; int *chars; if (strNil(s) || strNil(*arg2)) { *res = GDKstrdup(str_nil); + } else if ((n2 = strlen(*arg2)) == 0) { + *res = GDKstrdup(*arg1); } else { - chars = trimchars(*arg2, ); + chars = trimchars(*arg2, , n2); if (chars == NULL) throw(MAL, "str.trim", SQLSTATE(HY013) MAL_MALLOC_FAIL); len = strlen(s); @@ -3802,15 +3802,15 @@ str STRLtrim2(str *res, const str *arg1, const str *arg2) { const char *s = *arg1; - size_t len; - size_t n; - size_t nchars; + size_t len, n, nchars, n2; int *chars; if (strNil(s) || strNil(*arg2)) { *res = GDKstrdup(str_nil); + } else if ((n2 = strlen(*arg2)) == 0) { + *res = GDKstrdup(*arg1); } else { - chars = trimchars(*arg2, ); + chars = trimchars(*arg2, , n2); if (chars == NULL) throw(MAL, "str.trim", SQLSTATE(HY013) MAL_MALLOC_FAIL); len = strlen(s); @@ -3829,15 +3829,15 @@ str STRRtrim2(str *res, const str *arg1, const str *arg2) { const char *s = *arg1; - size_t len; - size_t n; - size_t nchars; + size_t len, n, nchars, n2; int *chars; if (strNil(s) || strNil(*arg2)) { *res = GDKstrdup(str_nil); + } else if ((n2 = strlen(*arg2)) == 0) { + *res = GDKstrdup(*arg1); } else { - chars = trimchars(*arg2, ); + chars = trimchars(*arg2, , n2); if (chars == NULL) throw(MAL, "str.trim", SQLSTATE(HY013) MAL_MALLOC_FAIL); len = strlen(s); 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 @@ -2213,7 +2213,7 @@ rel2bin_join(backend *be, sql_rel *rel, char *handled = SA_ZNEW_ARRAY(sql->sa, char, list_length(rel->exps)); /* get equi-joins/filters first */ - if (list_length(rel->exps) > 1) { + if (list_length(rel->exps) > 1 || is_outerjoin(rel->op)) { for( en = rel->exps->h, i=0; en; en = en->next, i++) { sql_exp *e = en->data; 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 @@ -1918,13 +1918,13 @@ stmt_join_cand(backend *be, stmt *op1, s MalBlkPtr mb = be->mb; InstrPtr q = NULL; int left = (cmptype == cmp_left); - const char *sjt = "join"; + const char *sjt = joinRef; (void)anti; if (left) { cmptype = cmp_equal; - sjt = "leftjoin"; + sjt = leftjoinRef; } if (op1->nr < 0 || op2->nr < 0) return NULL; diff --git a/sql/test/SQLancer/Tests/SingleServer b/sql/test/SQLancer/Tests/SingleServer --- a/sql/test/SQLancer/Tests/SingleServer +++ b/sql/test/SQLancer/Tests/SingleServer @@ -0,0 +1,1 @@ +--set raw_strings=true diff --git a/sql/test/SQLancer/Tests/sqlancer01.sql b/sql/test/SQLancer/Tests/sqlancer01.sql --- a/sql/test/SQLancer/Tests/sqlancer01.sql +++ b/sql/test/SQLancer/Tests/sqlancer01.sql @@ -25,7 +25,7 @@ insert into integers(i) values(((length(reverse('8 \rcr੧[bp1eMY쫺4j5s뮯!>(((- (- (528640982)))&(ascii('528640982')); --Bug 6885 SELECT i from integers order by i; -- NULL -- 0 -select reverse('8 \rcr੧[bp1eMY쫺4j5s뮯!https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Merged with Jun2020
Changeset: 551b12410f86 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=551b12410f86 Added Files: sql/test/SQLancer/Tests/SingleServer Modified Files: monetdb5/modules/atoms/str.c sql/server/rel_optimizer.c sql/server/rel_rewriter.c sql/server/rel_select.c sql/server/rel_unnest.c sql/server/sql_parser.y sql/test/BugTracker-2017/Tests/date-arithmetic.Bug-6415.sql sql/test/SQLancer/Tests/sqlancer01.sql sql/test/SQLancer/Tests/sqlancer01.stable.out testing/Mtest.py.in Branch: default Log Message: Merged with Jun2020 diffs (truncated from 760 to 300 lines): diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c --- a/monetdb5/modules/atoms/str.c +++ b/monetdb5/modules/atoms/str.c @@ -3989,23 +3989,26 @@ STRSubstitute(str *res, const str *arg1, const char *pfnd; char *fnd; - if (strNil(s)) { + if (strNil(s) || strNil(src) || strNil(dst)) { if ((*res = GDKstrdup(str_nil)) == NULL) throw(MAL, "str.substitute", SQLSTATE(HY013) MAL_MALLOC_FAIL); return MAL_SUCCEED; } + if (!lsrc || !l) { /* s/src is an empty string, there's nothing to substitute */ + if ((*res = GDKstrdup(s)) == NULL) + throw(MAL, "str.substitute", SQLSTATE(HY013) MAL_MALLOC_FAIL); + return MAL_SUCCEED; + } n = l + ldst; - if (repeat && ldst > lsrc && lsrc) { + if (repeat && ldst > lsrc) n = (ldst * l) / lsrc; /* max length */ - } + buf = *res = GDKmalloc(n); if (*res == NULL) throw(MAL, "str.substitute", SQLSTATE(HY013) MAL_MALLOC_FAIL); pfnd = s; - if (lsrc == 0) - lsrc = 1; /* make sure we make progress */ do { fnd = strstr(pfnd, src); if (fnd == NULL) diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -2491,7 +2491,7 @@ static sql_rel * rel_remove_redundant_join(mvc *sql, sql_rel *rel, int *changes) { (void)sql; - if (is_join(rel->op) || is_semi(rel->op)) { + if ((is_join(rel->op) || is_semi(rel->op)) && !list_empty(rel->exps)) { sql_rel *l = rel->l, *r = rel->r, *b, *p = NULL, *j; if (is_basetable(l->op) && is_simple_project(r->op) && need_distinct(r)) { @@ -3976,8 +3976,11 @@ exp_merge_project_rse( mvc *sql, sql_exp } } else if (is_convert(e->type)) { sql_exp *n = exp_merge_project_rse(sql, e->l); - if (n && n != e->l) - return exp_convert(sql->sa, n, exp_fromtype(e), exp_totype(e)); + if (n && n != e->l) { + n = exp_convert(sql->sa, n, exp_fromtype(e), exp_totype(e)); + exp_setname(sql->sa, n, exp_relname(e), exp_name(e)); + return n; + } } return e; } diff --git a/sql/server/rel_rewriter.c b/sql/server/rel_rewriter.c --- a/sql/server/rel_rewriter.c +++ b/sql/server/rel_rewriter.c @@ -30,6 +30,9 @@ exps_simplify_exp(mvc *sql, list *exps, needed = (exp_is_true(sql, e) || exp_is_false(sql, e) || (is_compare(e->type) && e->flag == cmp_or)); } + /* if there's only one expression and it is false, we have to keep it */ + if (list_length(exps) == 1 && exp_is_false(sql, exps->h->data)) + return exps; if (needed) { list *nexps = sa_list(sql->sa); sql->caching = 0; diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -2323,10 +2323,7 @@ rel_logical_value_exp(sql_query *query, return NULL; if (!(rs = rel_logical_value_exp(query, rel, ro, f, ek))) return NULL; - if (sc->token == SQL_OR) - return rel_binop_(sql, rel ? *rel : NULL, ls, rs, NULL, "or", card_value); - else - return rel_binop_(sql, rel ? *rel : NULL, ls, rs, NULL, "and", card_value); + return rel_binop_(sql, rel ? *rel : NULL, ls, rs, NULL, sc->token == SQL_OR ? "or": "and", card_value); } case SQL_FILTER: /* [ x,..] filter [ y,..] */ @@ -2518,23 +2515,11 @@ rel_logical_value_exp(sql_query *query, re1 = tmp; } - if (sc->token == SQL_NOT_BETWEEN) { - if (!(e1 = rel_binop_(sql, rel ? *rel : NULL, le, re1, NULL, "<", card_value))) - return NULL; - if (!(e2 = rel_binop_(sql, rel ? *rel : NULL, le, re2, NULL, ">", card_value))) -
MonetDB: default - Merged with Jun2020
Changeset: d5e5a3bba7df for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d5e5a3bba7df Added Files: sql/test/SQLancer/Tests/All sql/test/SQLancer/Tests/sqlancer01.sql sql/test/SQLancer/Tests/sqlancer01.stable.err sql/test/SQLancer/Tests/sqlancer01.stable.out Modified Files: sql/backends/monet5/UDF/udf/udf.c sql/backends/monet5/rel_bin.c sql/server/rel_exp.c Branch: default Log Message: Merged with Jun2020 diffs (truncated from 318 to 300 lines): diff --git a/sql/backends/monet5/UDF/udf/udf.c b/sql/backends/monet5/UDF/udf/udf.c --- a/sql/backends/monet5/UDF/udf/udf.c +++ b/sql/backends/monet5/UDF/udf/udf.c @@ -27,9 +27,7 @@ UDFreverse_(char **ret, const char *src) if (strNil(src)) { *ret = GDKstrdup(str_nil); if (*ret == NULL) - throw(MAL, "udf.reverse", - "failed to create copy of str_nil"); - + throw(MAL, "udf.reverse", "failed to create copy of str_nil"); return MAL_SUCCEED; } @@ -37,13 +35,48 @@ UDFreverse_(char **ret, const char *src) len = strlen(src); *ret = dst = GDKmalloc(len + 1); if (dst == NULL) - throw(MAL, "udf.reverse", - "failed to allocate string of length %zu", len + 1); + throw(MAL, "udf.reverse", "failed to allocate string of length %zu", len + 1); - /* copy characters from src to dst in reverse order */ dst[len] = 0; - while (len > 0) - *dst++ = src[--len]; + /* all strings in MonetDB are encoded using UTF-8; we must +* make sure that the reversed string is also encoded in valid +* UTF-8, so we treat multibyte characters as single units */ + while (*src) { + if ((*src & 0xF8) == 0xF0) { + /* 4 byte UTF-8 sequence */ + assert(len >= 4); + dst[len - 4] = *src++; + assert((*src & 0xC0) == 0x80); + dst[len - 3] = *src++; + assert((*src & 0xC0) == 0x80); + dst[len - 2] = *src++; + assert((*src & 0xC0) == 0x80); + dst[len - 1] = *src++; + len -= 4; + } else if ((*src & 0xF0) == 0xE0) { + /* 3 byte UTF-8 sequence */ + assert(len >= 3); + dst[len - 3] = *src++; + assert((*src & 0xC0) == 0x80); + dst[len - 2] = *src++; + assert((*src & 0xC0) == 0x80); + dst[len - 1] = *src++; + len -= 3; + } else if ((*src & 0xE0) == 0xC0) { + /* 2 byte UTF-8 sequence */ + assert(len >= 2); + dst[len - 2] = *src++; + assert((*src & 0xC0) == 0x80); + dst[len - 1] = *src++; + len -= 2; + } else { + /* 1 byte UTF-8 "sequence" */ + assert(len >= 1); + assert((*src & 0x80) == 0); + dst[--len] = *src++; + } + } + assert(len == 0); return MAL_SUCCEED; } 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 @@ -880,8 +880,6 @@ exp_bin(backend *be, sql_exp *e, stmt *l int swapped = 0, is_select = 0; sql_exp *re = e->r, *re2 = e->f; - assert((reduce && !depth) || e->flag == cmp_in || e->flag == cmp_notin); - /* general predicate, select and join */ if (e->flag == cmp_filter) { list *args; @@ -1070,7 +1068,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l } } else { if (r2) { - if (l->nrcols == 0 && r->nrcols == 0 && r2->nrcols == 0) { + if (!reduce || (l->nrcols == 0 && r->nrcols == 0 && r2->nrcols == 0)) { sql_subtype *bt = sql_bind_localtype("bit"); sql_subfunc *lf = sql_bind_func(sql->sa, sql->session->schema, compare_func(range2lcompare(e->flag), 0), @@ -1113,7 +,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l } } else { /* value compare or select */ - if (l->nrcols == 0 && r->nrcols == 0 && (e->flag == mark_in || e->flag == mark_notin)) { + if (!reduce || (l->nrcols == 0
MonetDB: default - Merged with Jun2020
Changeset: f27dfe585138 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f27dfe585138 Added Files: sql/test/Tests/hot_snapshot.py sql/test/Tests/hot_snapshot.stable.err sql/test/Tests/hot_snapshot.stable.out sql/test/Tests/hot_snapshot_bz2.py sql/test/Tests/hot_snapshot_bz2.stable.err sql/test/Tests/hot_snapshot_bz2.stable.out sql/test/Tests/hot_snapshot_gz.py sql/test/Tests/hot_snapshot_gz.stable.err sql/test/Tests/hot_snapshot_gz.stable.out sql/test/Tests/hot_snapshot_lz4.py sql/test/Tests/hot_snapshot_lz4.stable.err sql/test/Tests/hot_snapshot_lz4.stable.out sql/test/Tests/hot_snapshot_xz.py sql/test/Tests/hot_snapshot_xz.stable.err sql/test/Tests/hot_snapshot_xz.stable.out Removed Files: sql/test/Tests/hot-snapshot-bz2.py sql/test/Tests/hot-snapshot-bz2.stable.err sql/test/Tests/hot-snapshot-bz2.stable.out sql/test/Tests/hot-snapshot-gz.py sql/test/Tests/hot-snapshot-gz.stable.err sql/test/Tests/hot-snapshot-gz.stable.out sql/test/Tests/hot-snapshot-lz4.py sql/test/Tests/hot-snapshot-lz4.stable.err sql/test/Tests/hot-snapshot-lz4.stable.out sql/test/Tests/hot-snapshot-xz.py sql/test/Tests/hot-snapshot-xz.stable.err sql/test/Tests/hot-snapshot-xz.stable.out sql/test/Tests/hot-snapshot.py sql/test/Tests/hot-snapshot.stable.err sql/test/Tests/hot-snapshot.stable.out sql/test/Tests/hot_snapshot_compression.py Modified Files: common/stream/stream.c monetdb5/modules/mal/pcre.c sql/backends/monet5/sql_subquery.c sql/server/rel_optimizer.c sql/server/rel_select.c sql/server/rel_unnest.c sql/server/rel_unnest.h sql/server/sql_query.c sql/server/sql_query.h sql/storage/bat/bat_logger.c sql/storage/store.c sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out.int128 sql/test/BugTracker-2013/Tests/syntaxerror.Bug-3399.stable.out sql/test/Tests/All sql/test/bugs/Tests/select_select_bug.stable.out sql/test/subquery/Tests/correlated.stable.out sql/test/subquery/Tests/subquery.stable.out sql/test/subquery/Tests/subquery3.stable.err sql/test/subquery/Tests/subquery3.stable.out sql/test/subquery/Tests/subquery4.stable.out sql/test/subquery/Tests/subquery5.stable.out sql/test/subquery/Tests/subquery6.sql sql/test/subquery/Tests/subquery6.stable.err sql/test/subquery/Tests/subquery6.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 1953 to 300 lines): diff --git a/common/stream/stream.c b/common/stream/stream.c --- a/common/stream/stream.c +++ b/common/stream/stream.c @@ -1824,8 +1824,15 @@ stream_lz4close(stream *s) lz4_stream *lz4 = s->stream_data.p; if (lz4) { - stream_lz4flush(s); if(!s->readonly) { + char final_bytes[128]; // 4 would probably suffice + stream_lz4flush(s); + size_t remainder = LZ4F_compressEnd(lz4->context.comp_context, final_bytes, sizeof(final_bytes), NULL); + // no channel to return an error from here :( + if (!LZ4F_isError(remainder)) { + // again, hope for the best + (void) fwrite(final_bytes, 1, remainder, lz4->fp); + } (void) LZ4F_freeCompressionContext(lz4->context.comp_context); } else { (void) LZ4F_freeDecompressionContext(lz4->context.dec_context); diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c --- a/monetdb5/modules/mal/pcre.c +++ b/monetdb5/modules/mal/pcre.c @@ -233,7 +233,7 @@ myucslen(const uint32_t *ucs) return i; } -static int +static inline int mywstrncasecmp(const char *restrict s1, const uint32_t *restrict s2, size_t n2) { uint32_t c1; @@ -261,7 +261,7 @@ mywstrncasecmp(const char *restrict s1, return 0; } -static int +static inline int mystrcasecmp(const char *s1, const char *s2) { uint32_t c1, c2; @@ -289,7 +289,7 @@ mystrcasecmp(const char *s1, const char } } -static int +static inline int mywstrcasecmp(const char *restrict s1, const uint32_t *restrict s2) { uint32_t c1; @@ -315,7 +315,7 @@ mywstrcasecmp(const char *restrict s1, c } } -static const char * +static inline const char * mywstrcasestr(const char *restrict haystack, const uint32_t *restrict wneedle) { size_t nlen = myucslen(wneedle); @@ -394,7 +394,7 @@ is_strcmpable(const char *pat, const cha return strlen(esc) == 0 ||
MonetDB: default - Merged with Jun2020
Changeset: 9405b15e3909 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9405b15e3909 Modified Files: clients/examples/perl/sqlsample.pl clients/examples/python/sqlsample.py monetdb5/modules/atoms/mtime.c sql/common/sql_types.c sql/server/rel_optimizer.c sql/server/rel_unnest.c sql/test/mapi/Tests/perl_dbi.stable.out sql/test/mapi/Tests/python3_dbapi.stable.out sql/test/miscellaneous/Tests/groupby_error.sql sql/test/miscellaneous/Tests/groupby_error.stable.out tools/merovingian/client/Tests/All Branch: default Log Message: Merged with Jun2020 diffs (231 lines): diff --git a/clients/examples/perl/sqlsample.pl b/clients/examples/perl/sqlsample.pl --- a/clients/examples/perl/sqlsample.pl +++ b/clients/examples/perl/sqlsample.pl @@ -37,7 +37,7 @@ my $dbh = DBI->connect( $dsn, } { # deliberately executing a wrong SQL statement: - my $sth = $dbh->prepare('values ();'); + my $sth = $dbh->prepare('select commit_action, access from tables group by access;'); eval { $sth->execute }; print "ERROR REPORTED: $@" if $@; } $dbh->do('create table perl_table (i smallint,s string);'); diff --git a/clients/examples/python/sqlsample.py b/clients/examples/python/sqlsample.py --- a/clients/examples/python/sqlsample.py +++ b/clients/examples/python/sqlsample.py @@ -21,7 +21,7 @@ print(cursor.fetchone()) # deliberately executing a wrong SQL statement: try: -cursor.execute('values ();') +cursor.execute('select commit_action, access from tables group by access;') except pymonetdb.OperationalError as e: print(e) diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c --- a/monetdb5/modules/atoms/mtime.c +++ b/monetdb5/modules/atoms/mtime.c @@ -874,10 +874,35 @@ MTIMEstr_to_timestamp(timestamp *ret, co t = time(NULL); localtime_r(, ); tm.tm_sec = tm.tm_min = tm.tm_hour = 0; + tm.tm_isdst = -1; if (strptime(*s, *format, ) == NULL) throw(MAL, "mtime.str_to_timestamp", "format '%s', doesn't match timestamp '%s'", *format, *s); - *ret = timestamp_fromtime(mktime()); + *ret = timestamp_create(date_create(tm.tm_year + 1900, + tm.tm_mon + 1, + tm.tm_mday), + daytime_create(tm.tm_hour, + tm.tm_min, + tm.tm_sec == 60 ? 59 : tm.tm_sec, + 0)); + /* if strptime filled in DST information (tm_isdst >= 0), then the +* time is in system local time and we convert to GMT by +* subtracting the time zone offset, else we don't touch the time +* returned because it is assumed to already be in GMT */ + if (tm.tm_isdst >= 0) { + int isdst = 0; + int tz = local_timezone(); + /* if strptime's information doesn't square with our own +* information about having or not having DST, we compensate +* an hour */ + if (tm.tm_isdst > 0 && isdst == 0) { + tz += 3600; + } else if (tm.tm_isdst == 0 && isdst > 0) { + tz -= 3600; + } + + *ret = timestamp_add_usec(*ret, -tz * LL_CONSTANT(100)); + } if (is_timestamp_nil(*ret)) throw(MAL, "mtime.str_to_timestamp", "bad timestamp '%s'", *s); return MAL_SUCCEED; diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c --- a/sql/common/sql_types.c +++ b/sql/common/sql_types.c @@ -1350,7 +1350,7 @@ sqltypeinit( sql_allocator *sa) sql_create_aggr(sa, "prod", "aggr", "prod", FALSE, LargestINT, 1, INT); sql_create_aggr(sa, "prod", "aggr", "prod", FALSE, LargestINT, 1, LNG); #ifdef HAVE_HGE - if (HAVE_HGE) + if (have_hge) sql_create_aggr(sa, "prod", "aggr", "prod", FALSE, LargestINT, 1, HGE); #endif diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -2480,6 +2480,50 @@ has_no_selectivity(mvc *sql, sql_rel *re return rel; } +/* + * Remove a redundant join + * + * join (L, Distinct Project(join(L,P) [ p.key == l.lkey]) [p.key]) [ p.key == l.lkey] + * => + * join(L, P) [p.key==l.lkey] + */ +static sql_rel * +rel_remove_redundant_join(mvc *sql, sql_rel *rel, int *changes) +{ + (void)sql; + if (is_join(rel->op) || is_semi(rel->op)) { + sql_rel *l = rel->l, *r = rel->r, *b, *p = NULL, *j; + + if
MonetDB: default - Merged with Jun2020
Changeset: 6511c5ec6d32 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6511c5ec6d32 Modified Files: sql/backends/monet5/rel_bin.c sql/server/rel_optimizer.c sql/test/BugTracker-2017/Tests/sqlitelogictest-hidden-alias.Bug-6495.stable.out sql/test/BugTracker-2018/Tests/sqlitelogictest-having-not-null-not-in.Bug-6557.stable.out sql/test/analytics/Tests/analytics16.stable.err sql/test/miscellaneous/Tests/groupby_error.stable.out Branch: default Log Message: Merged with Jun2020 diffs (100 lines): 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 @@ -21,6 +21,7 @@ #include "sql_optimizer.h" #include "sql_gencode.h" #include "mal_builder.h" +#include "opt_prelude.h" #define OUTER_ZERO 64 @@ -1873,7 +1874,14 @@ rel2bin_table(backend *be, sql_rel *rel, /* use a simple nested loop solution for this case, ie * output a table of (input) row-ids, the output of the table producing function */ - InstrPtr q = newStmt(be->mb, "sql", "unionfunc"); + /* make sure the input for sql.unionfunc are bats */ + if (ids) + ids = column(be, ids); + if (ops) + for (node *en = ops->h; en; en = en->next) + en->data = column(be, (stmt *) en->data); + + InstrPtr q = newStmt(be->mb, sqlRef, "unionfunc"); /* Generate output rowid column and output of function f */ for(i=0; m; m = m->next, i++) { sql_exp *e = m->data; diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -2523,7 +2523,8 @@ rel_distinct_project2groupby(mvc *sql, s if (rel->op == op_project && rel->l && !rel->r /* no order by */ && need_distinct(rel) && exps_card(rel->exps) <= CARD_ATOM) { set_nodistinct(rel); - rel->l = rel_topn(sql->sa, rel->l, append(sa_list(sql->sa), exp_atom_lng(sql->sa, 1))); + if (rel->card > CARD_ATOM) /* if the projection just contains constants, then no topN is needed */ + rel->l = rel_topn(sql->sa, rel->l, append(sa_list(sql->sa), exp_atom_lng(sql->sa, 1))); } /* rewrite distinct project [ pk ] ( select ( table ) [ e op val ]) diff --git a/sql/test/BugTracker-2017/Tests/sqlitelogictest-hidden-alias.Bug-6495.stable.out b/sql/test/BugTracker-2017/Tests/sqlitelogictest-hidden-alias.Bug-6495.stable.out --- a/sql/test/BugTracker-2017/Tests/sqlitelogictest-hidden-alias.Bug-6495.stable.out +++ b/sql/test/BugTracker-2017/Tests/sqlitelogictest-hidden-alias.Bug-6495.stable.out @@ -40,7 +40,7 @@ stdout of test 'sqlitelogictest-hidden-a % bigint # type % 1 # length #SELECT DISTINCT + MAX ( DISTINCT - col1 ) col2 FROM tab0 WHERE - col3 + + 72 IS NULL; -% . # table_name +% sys. # table_name % col2 # name % double # type % 24 # length diff --git a/sql/test/BugTracker-2018/Tests/sqlitelogictest-having-not-null-not-in.Bug-6557.stable.out b/sql/test/BugTracker-2018/Tests/sqlitelogictest-having-not-null-not-in.Bug-6557.stable.out --- a/sql/test/BugTracker-2018/Tests/sqlitelogictest-having-not-null-not-in.Bug-6557.stable.out +++ b/sql/test/BugTracker-2018/Tests/sqlitelogictest-having-not-null-not-in.Bug-6557.stable.out @@ -52,7 +52,7 @@ stdout of test 'sqlitelogictest-having-n % 3 # length [ 126 ] #SELECT DISTINCT COUNT(*) FROM tab0 WHERE NOT col2 NOT BETWEEN ( 35 ) AND ( NULL ); -% .%1 # table_name +% sys.%1 # table_name % %1 # name % bigint # type % 1 # length diff --git a/sql/test/miscellaneous/Tests/groupby_error.stable.out b/sql/test/miscellaneous/Tests/groupby_error.stable.out --- a/sql/test/miscellaneous/Tests/groupby_error.stable.out +++ b/sql/test/miscellaneous/Tests/groupby_error.stable.out @@ -426,6 +426,32 @@ project ( % bigint, bigint # type % 2, 3 # length [ 87, -37 ] +#SELECT DISTINCT CAST(- CAST ( CASE 81 WHEN 48 - - 3 / - - 47 - - CAST ( NULL AS INTEGER ) THEN NULL WHEN COUNT ( * ) THEN + - 91 + + 43 ELSE + - 0 END AS INTEGER ) AS BIGINT) AS col0, CAST(- 27 * + 43 AS BIGINT); +% ., . # table_name +% col0,%3 # name +% bigint, bigint # type +% 1, 5 # length +[ 0, -1161 ] +#SELECT DISTINCT CAST(66 * - + CAST ( - - COUNT ( * ) AS INTEGER ) * 54 * + CASE 68 WHEN - 56 * + CAST ( NULL AS INTEGER ) + + + 47 THEN +#- 83 ELSE + 59 + - COUNT (
MonetDB: default - Merged with Jun2020
Changeset: e6284d922f04 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e6284d922f04 Modified Files: clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 clients/Tests/mclient-uri.stable.out clients/Tests/mclient-uri.stable.out.Windows gdk/gdk_calc.c geom/sql/pg_regression/Tests/dump.stable.out monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows monetdb5/mal/Tests/tst1506.stable.out monetdb5/modules/mal/calc.c monetdb5/optimizer/opt_remap.c sql/backends/monet5/Tests/optimizers.stable.out sql/backends/monet5/Tests/rapi09.stable.out sql/backends/monet5/Tests/simpleSQL.stable.out sql/backends/monet5/UDF/udf/Tests/udf-fuse.stable.out sql/backends/monet5/UDF/udf/Tests/udf-reverse.stable.out sql/backends/monet5/rel_bin.c sql/backends/monet5/sql.h sql/backends/monet5/sql.mal sql/backends/monet5/sql_bat2time.c sql/backends/monet5/sql_cast.c sql/backends/monet5/sql_cast.h sql/backends/monet5/sql_cast_impl_down_from_flt.h sql/backends/monet5/sql_cast_impl_int.h sql/backends/monet5/sql_cast_impl_up_to_flt.h sql/backends/monet5/sql_decimal.mal sql/backends/monet5/sql_decimal.mal.sh sql/backends/monet5/sql_decimal_hge.mal sql/backends/monet5/sql_decimal_hge.mal.sh sql/backends/monet5/sql_hge.mal sql/backends/monet5/sql_round_impl.h sql/backends/monet5/sql_statement.c sql/backends/monet5/sql_statement.h sql/jdbc/tests/Tests/Test_PSmetadata.stable.out sql/server/rel_optimizer.c sql/server/rel_select.c sql/server/rel_unnest.c sql/test/BugDay_2005-10-06_2.8/Tests/select_null.stable.out sql/test/BugDay_2005-10-06_2.8/Tests/string_quotes.SF-919539.stable.out sql/test/BugDay_2005-10-06_2.9.3/Tests/basic_arithmetics.SF-922252.stable.out sql/test/BugDay_2005-10-06_2.9.3/Tests/select_not_true.SF-1314945.stable.out sql/test/BugDay_2005-10-06_2.9.3/Tests/set_types.SF-932360.stable.out sql/test/BugDay_2005-12-19_2.9.3/Tests/cast_bigint_to_int.SF-1211903.stable.out sql/test/BugTracker-2009/Tests/AVG_of_SQRT.SF-2757642.stable.out sql/test/BugTracker-2009/Tests/BOM.SF-2787813.stable.out sql/test/BugTracker-2009/Tests/Division_by_zero_error.SF-2791361.stable.out sql/test/BugTracker-2009/Tests/Floating_point_exception.SF-2791356.stable.out sql/test/BugTracker-2009/Tests/addmonths_missing.SF-2854949.stable.out sql/test/BugTracker-2009/Tests/arithmetic-small-values-null.SF-2921310.stable.out sql/test/BugTracker-2009/Tests/bit_and.SF-2850341.stable.out.int128 sql/test/BugTracker-2009/Tests/coercion.stable.out sql/test/BugTracker-2009/Tests/count_bug.SF-2604583.stable.out sql/test/BugTracker-2009/Tests/explain_gives_crash.SF-2741829.stable.out sql/test/BugTracker-2009/Tests/function_call_not_handled.SF-2864179.stable.out sql/test/BugTracker-2009/Tests/pow_operator.SF-2812721.stable.out sql/test/BugTracker-2009/Tests/restart_with_large_int.SF-2846238.stable.out sql/test/BugTracker-2009/Tests/segfault_when_quitting_debugger.SF-2538837.stable.out sql/test/BugTracker-2009/Tests/set_and_arg_null.SF-2812729.stable.out sql/test/BugTracker-2010/Tests/constants-optimizer.Bug-2317.stable.out sql/test/BugTracker-2010/Tests/crash_on_where_in.Bug-2333.stable.out sql/test/BugTracker-2010/Tests/unicode-bom.Bug-2641.stable.out sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.stable.out.int128 sql/test/BugTracker-2012/Tests/aggregate_vs_positional_column_crash.Bug-3085.stable.out sql/test/BugTracker-2012/Tests/not-equal-Bug.3139.stable.out sql/test/BugTracker-2012/Tests/simple_select.Bug-2988.stable.out sql/test/BugTracker-2013/Tests/Cannot_Find_Column_Type.Bug-3394.stable.out sql/test/BugTracker-2013/Tests/aggregates-typing-issues.Bug-3277.stable.out sql/test/BugTracker-2013/Tests/alter_resets_readonly.Bug-3362.stable.out sql/test/BugTracker-2013/Tests/correlated_select.Bug-3250.stable.out sql/test/BugTracker-2013/Tests/decimal-cast.Bug-3310.stable.out sql/test/BugTracker-2013/Tests/env_errors.Bug-3370.stable.out sql/test/BugTracker-2013/Tests/iso8601_weekofyear.Bug-3232.stable.out sql/test/BugTracker-2013/Tests/nested_concat_query.Bug-3408.stable.out sql/test/BugTracker-2013/Tests/php-size-limit-bug.stable.out sql/test/BugTracker-2013/Tests/recursion.stable.out
MonetDB: default - Merged with Jun2020
Changeset: 15f8f49fa732 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=15f8f49fa732 Modified Files: gdk/gdk_bbp.c gdk/gdk_cross.c gdk/gdk_logger.c gdk/gdk_posix.c gdk/gdk_storage.c gdk/gdk_string.c gdk/gdk_system.c gdk/gdk_tracer.c gdk/gdk_utils.c sql/server/rel_exp.c sql/server/rel_exp.h sql/server/rel_optimizer.c sql/server/rel_select.c sql/server/rel_unnest.c sql/server/sql_parser.y sql/test/BugTracker-2017/Tests/lateral.Bug-6310.stable.err sql/test/BugTracker-2017/Tests/lateral.Bug-6310.stable.out sql/test/mergetables/Tests/sqlsmith-exists2.sql sql/test/mergetables/Tests/sqlsmith-exists2.stable.out sql/test/miscellaneous/Tests/groupby_error.sql sql/test/miscellaneous/Tests/groupby_error.stable.out sql/test/miscellaneous/Tests/simple_plans.stable.out sql/test/subquery/Tests/subquery6.sql sql/test/subquery/Tests/subquery6.stable.err sql/test/subquery/Tests/subquery6.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 2127 to 300 lines): diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -652,8 +652,8 @@ fixdatebats(void) } fp = fopen(filename, "w"); if (fp == NULL) { - TRC_CRITICAL(GDK, "cannot create file %s: %s\n", -filename, GDKstrerror(errno, (char[128]){0}, 128)); + GDKsyserror("cannot create file %s\n", + filename); return GDK_FAIL; } fclose(fp); @@ -1137,7 +1137,7 @@ BBPaddfarm(const char *dirname, int role return GDK_FAIL; } } else { - GDKerror("%s: cannot create directory\n", dirname); + GDKsyserror("%s: cannot create directory\n", dirname); return GDK_FAIL; } } @@ -1161,7 +1161,6 @@ BBPaddfarm(const char *dirname, int role * database */ bbpdir = GDKfilepath(i, BATDIR, "BBP", "dir"); if (bbpdir == NULL) { - GDKerror("malloc failed\n"); return GDK_FAIL; } if (stat(bbpdir, ) != -1 || errno != ENOENT) { @@ -1172,7 +1171,6 @@ BBPaddfarm(const char *dirname, int role GDKfree(bbpdir); bbpdir = GDKfilepath(i, BAKDIR, "BBP", "dir"); if (bbpdir == NULL) { - GDKerror("malloc failed\n"); return GDK_FAIL; } if (stat(bbpdir, ) != -1 || errno != ENOENT) { @@ -1332,7 +1330,6 @@ BBPinit(void) if (j == i) { char *d = GDKfilepath(i, NULL, BATDIR, NULL); if (d == NULL) { - TRC_CRITICAL(GDK, "malloc failed\n"); return GDK_FAIL; } BBPdiskscan(d, strlen(d) - strlen(BATDIR)); @@ -2953,7 +2950,7 @@ BBPprepare(bool subcommit) ret = BBPrecover(0); if (ret == GDK_SUCCEED) { if (mkdir(bakdirpath, MONETDB_DIRMODE) < 0 && errno != EEXIST) { - GDKsyserror("BBPprepare: cannot create directory %s\n", bakdirpath); + GDKsyserror("cannot create directory %s\n", bakdirpath); ret = GDK_FAIL; } /* if BAKDIR already exists, don't signal error */ @@ -2963,7 +2960,7 @@ BBPprepare(bool subcommit) if (ret == GDK_SUCCEED && start_subcommit) { /* make a new SUBDIR (subdir of BAKDIR) */ if (mkdir(subdirpath, MONETDB_DIRMODE) < 0) { - GDKsyserror("BBPprepare: cannot create directory %s\n", subdirpath); + GDKsyserror("cannot create directory %s\n", subdirpath); ret = GDK_FAIL; } TRC_DEBUG(IO_, "mkdir %s = %d\n", subdirpath, (int) ret); @@ -3262,7 +3259,6 @@ force_move(int farmid, const char *srcdi strncpy(srcpath, name, len); srcpath[len] = '\0'; if(!(dstpath = GDKfilepath(farmid, dstdir, srcpath, NULL))) { - GDKsyserror("force_move: malloc fail\n");
MonetDB: default - Merged with Jun2020
Changeset: 876b180dc580 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=876b180dc580 Added Files: sql/test/BugTracker-2020/Tests/ilike-matches.Bug-6864.sql sql/test/BugTracker-2020/Tests/ilike-matches.Bug-6864.stable.err sql/test/BugTracker-2020/Tests/ilike-matches.Bug-6864.stable.out Modified Files: buildtools/conf/Maddlog configure.ag gdk/gdk_batop.c monetdb5/modules/mal/pcre.c sql/server/rel_optimizer.c sql/server/rel_unnest.c sql/test/BugTracker-2016/Tests/memory-consumption-query-PLAN-25joins.Bug-3972.stable.out sql/test/BugTracker-2020/Tests/All Branch: default Log Message: Merged with Jun2020 diffs (truncated from 523 to 300 lines): diff --git a/buildtools/conf/Maddlog b/buildtools/conf/Maddlog --- a/buildtools/conf/Maddlog +++ b/buildtools/conf/Maddlog @@ -123,7 +123,7 @@ fi case "$CL" in '') d=. -while [ ! -f $d/vertoo.data -a ! -f $d/ChangeLog -a ! -f $d/ChangeLog.$tag ]; do +while [ ! -f $d/.bumpversion.cfg -a ! -f $d/ChangeLog -a ! -f $d/ChangeLog.$tag ]; do if [ $d -ef / ]; then echo "$0: cannot find top directory of package" >&2 exit 1 diff --git a/configure.ag b/configure.ag --- a/configure.ag +++ b/configure.ag @@ -131,7 +131,7 @@ AS_CASE([$CC], # __GNUC_MINOR__, and __GNUC_PATCHLEVEL__ macros. CC="$CC -no-gcc"]) -AS_IF([test -f "$srcdir"/vertoo.data], +AS_IF([test -f "$srcdir"/.bumpversion.cfg], [ # Developers compiling from Mercurial: # default is --enable-strict --enable-assert --enable-debug --disable-optimize --enable-developer --enable-profiler=auto @@ -1989,15 +1989,15 @@ AM_CONDITIONAL([HAVE_LIDAR], [test "x$ha dnl check for profiler library AS_CASE([$enable_profiler], - [no], [have_profiler=no], + [no], [], [ PKG_CHECK_MODULES([PROFILER], [libprofiler], - [have_profiler=yes], - [have_profiler=no; why_not_profiler="(profiler library not found)"]) - AS_VAR_IF([have_profiler], [yes], [ + [enable_profiler=yes], + [enable_profiler=no; why_not_profiler="(profiler library not found)"]) + AS_VAR_IF([enable_profiler], [yes], [ AC_DEFINE([HAVE_LIBPROFILER], 1, [Define if you have the profiler library]) AC_SUBST([PKG_PROFILER], [libprofiler])])]) -AM_CONDITIONAL([HAVE_LIBPROFILER], [test x$have_profiler != xno]) +AM_CONDITIONAL([HAVE_LIBPROFILER], [test enable_profiler != xno]) #checks for header files @@ -2605,6 +2605,7 @@ for comp in \ 'optimize ' \ 'developer ' \ 'sanitizer ' \ + 'profiler ' \ ; do AS_VAR_COPY([dft], [dft_$comp]) AS_VAR_COPY([enable], [enable_$comp]) diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -865,6 +865,15 @@ BATreplace(BAT *b, BAT *p, BAT *n, bool return GDK_FAIL; } + BATiter bi = bat_iterator(b); + BATiter ni = bat_iterator(n); + if (BATcount(b) == 0 || + (b->tsorted && b->trevsorted && +n->tsorted && n->trevsorted && +ATOMcmp(b->ttype, BUNtail(bi, 0), BUNtail(ni, 0)) == 0)) { + return GDK_SUCCEED; + } + HASHdestroy(b); OIDXdestroy(b); IMPSdestroy(b); @@ -881,8 +890,6 @@ BATreplace(BAT *b, BAT *p, BAT *n, bool int (*atomcmp)(const void *, const void *) = ATOMcompare(b->ttype); const void *nil = ATOMnilptr(b->ttype); oid hseqend = b->hseqbase + BATcount(b); - BATiter bi = bat_iterator(b); - BATiter ni = bat_iterator(n); bool anynil = false; b->theap.dirty = true; @@ -2127,8 +2134,29 @@ BATconstant(oid hseq, int tailtype, cons ((hge *) p)[i] = *(hge *) v; break; #endif + case TYPE_str: + /* insert the first value, then just copy the +* offset lots of times */ + if (tfastins_nocheck(bn, 0, v, Tsize(bn)) != GDK_SUCCEED) { + BBPreclaim(bn); + return NULL; + } + char val[sizeof(var_t)]; + memcpy(val, bn->theap.base, bn->twidth); + if (bn->twidth == 1 && n > 1) { + /* single byte value: we have a +* function for that */ + memset(bn->theap.base + 1, val[0], n - 1); + } else { + char *p = bn->theap.base; + for (i = 1; i < n; i++) { + p += bn->twidth; +
MonetDB: default - Merged with Jun2020
Changeset: 17f9716d9992 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=17f9716d9992 Modified Files: sql/backends/monet5/rel_bin.c sql/server/rel_optimizer.c sql/server/rel_rel.c sql/server/rel_unnest.c sql/test/BugTracker-2016/Tests/memory-consumption-query-PLAN-25joins.Bug-3972.stable.out sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-2join-query.stable.out sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-explain-2join-view.stable.out sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-2join-query.stable.out sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-2join-view.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 651 to 300 lines): 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 @@ -2635,6 +2635,7 @@ rel2bin_semijoin(backend *be, sql_rel *r join = stmt_join(be, l, r, 0, cmp_all, 0, false); } } else { + right = subrel_project(be, right, refs, rel->r); stmt *l = bin_first_column(be, left); stmt *r = bin_first_column(be, right); join = stmt_join(be, l, r, 0, cmp_all, 0, false); diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -1946,6 +1946,31 @@ rel_push_topn_and_sample_down(mvc *sql, operator_type relation_type = is_topn(rel->op) ? op_topn : op_sample; sql_rel *(*func) (sql_allocator *, sql_rel *, list *) = is_topn(rel->op) ? rel_topn : rel_sample; + /* nested topN relations without offset */ + if (r && is_topn(rel->op) && is_topn(r->op) && list_length(rel->exps) == 1 && list_length(r->exps) == 1) { + sql_exp *topN1 = rel->exps->h->data, *topN2 = r->exps->h->data; + + if (topN1->l && topN2->l) { + atom *a1 = (atom *)topN1->l, *a2 = (atom *)topN2->l; + + if (a1->tpe.type->localtype == a2->tpe.type->localtype && !a1->isnull && !a2->isnull) { + if (atom_cmp(a1, a2) < 0) { + rel->l = r->l; + r->l = NULL; + rel_destroy(r); + (*changes)++; + return rel; + } else { + rel->l = NULL; + rel_destroy(rel); + rel = r; + (*changes)++; + return rel; + } + } + } + } + if (r && is_simple_project(r->op) && need_distinct(r)) return rel; @@ -6218,6 +6243,12 @@ rel_remove_join(mvc *sql, sql_rel *rel, static sql_rel * rel_push_project_up(mvc *sql, sql_rel *rel, int *changes) { + if (is_simple_project(rel->op) && rel->l && !rel_is_ref(rel)) { + sql_rel *l = rel->l; + if (is_simple_project(l->op)) + return rel_merge_projects(sql, rel, changes); + } + /* project/project cleanup is done later */ if (is_join(rel->op) || is_select(rel->op)) { node *n; @@ -7392,7 +7423,7 @@ rel_simplify_like_select(mvc *sql, sql_r static sql_exp * rel_simplify_predicates(mvc *sql, sql_rel *rel, sql_exp *e, int depth, int *changes) { - (void) depth; + (void)depth; if (is_select(rel->op) || is_join(rel->op) || is_semi(rel->op)) { if (is_atom(e->type) && ((!e->l && !e->r && !e->f) || e->r)) /* prepared statement parameter or argument */ return e; @@ -7426,8 +7457,7 @@ rel_simplify_predicates(mvc *sql, sql_re list *args = l->l; sql_exp *ie = args->h->data; - /* TODO, we have to fix the NOT NULL flag propagation on columns after an outer join, so we can remove the is_outerjoin check */ - if (!is_outerjoin(rel->op) && (!has_nil(ie) || exp_is_not_null(sql, ie))) { /* is null on something that is never null, is always false */ + if (!has_nil(ie) || exp_is_not_null(sql, ie)) { /* is null on something that is
MonetDB: default - merged with jun2020
Changeset: a499c5d05c9c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a499c5d05c9c Modified Files: sql/backends/monet5/rel_bin.c Branch: default Log Message: merged with jun2020 diffs (12 lines): 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 @@ -2364,7 +2364,7 @@ rel2bin_join(backend *be, sql_rel *rel, stmt *l = ld = stmt_mirror(be, bin_first_column(be, left)); if (rel->op == op_left || rel->op == op_full) ld = stmt_tdiff(be, ld, jl, NULL); - if (rel->single) { + if (rel->single && !list_empty(rel->exps)) { join = stmt_semijoin(be, l, jl, NULL, NULL, 0, true); jl = stmt_result(be, join, 0); jr = stmt_project(be, stmt_result(be, join, 1), jr); ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Merged with Jun2020
Changeset: 01a52e34518a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=01a52e34518a Modified Files: sql/common/sql_types.c sql/server/rel_rel.c sql/server/rel_select.c sql/test/miscellaneous/Tests/simple_plans.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 340 to 300 lines): diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c --- a/sql/common/sql_types.c +++ b/sql/common/sql_types.c @@ -575,8 +575,8 @@ sql_dup_subfunc(sql_allocator *sa, sql_f sql_arg *rarg = tn->data; sql_subtype *res, *r = >type; - /* same scale as the input */ - if (member && member->scale > scale) + /* same scale as the input if result has a scale */ + if (member && (r->type->eclass == EC_ANY || r->type->scale != SCALE_NONE) && member->scale > scale) scale = member->scale; digits = r->digits; if (!member) { diff --git a/sql/server/rel_rel.c b/sql/server/rel_rel.c --- a/sql/server/rel_rel.c +++ b/sql/server/rel_rel.c @@ -1296,7 +1296,6 @@ rel_push_select(mvc *sql, sql_rel *rel, return rel; } - /* ls and rs are the left and right expression of the join, e is the join expression. */ diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -1699,6 +1699,46 @@ rel_filter_exp_(mvc *sql, sql_rel *rel, } static sql_rel * +rel_compare_push_exp(mvc *sql, sql_rel *rel, sql_exp *e, sql_exp *ls, sql_exp *L, sql_exp *rs, sql_exp *R, sql_exp *rs2) +{ + if (rs->card <= CARD_ATOM && (exp_is_atom(rs) || exp_has_freevar(sql, rs) || exp_has_freevar(sql, ls)) && + (!rs2 || (rs2->card <= CARD_ATOM && (exp_is_atom(rs2) || exp_has_freevar(sql, rs2) { + if ((ls->card == rs->card && !rs2) || rel->processed) /* bin compare op */ + return rel_select(sql->sa, rel, e); + + if (/*is_semi(rel->op) ||*/ is_outerjoin(rel->op)) { + if ((is_left(rel->op) || is_full(rel->op)) && rel_find_exp(rel->l, ls)) { + rel_join_add_exp(sql->sa, rel, e); + return rel; + } else if ((is_right(rel->op) || is_full(rel->op)) && rel_find_exp(rel->r, ls)) { + rel_join_add_exp(sql->sa, rel, e); + return rel; + } + if (is_left(rel->op) && rel_find_exp(rel->r, ls)) { + rel->r = rel_push_select(sql, rel->r, L, e); + return rel; + } else if (is_right(rel->op) && rel_find_exp(rel->l, ls)) { + rel->l = rel_push_select(sql, rel->l, L, e); + return rel; + } + } + /* push select into the given relation */ + return rel_push_select(sql, rel, L, e); + } else { /* join */ + sql_rel *r; + if (/*is_semi(rel->op) ||*/ (is_outerjoin(rel->op) && !is_processed((rel { + rel_join_add_exp(sql->sa, rel, e); + return rel; + } + /* push join into the given relation */ + if ((r = rel_push_join(sql, rel, L, R, rs2, e)) != NULL) + return r; + rel_join_add_exp(sql->sa, rel, e); + return rel; + } +} + +static sql_rel * rel_compare_exp_(sql_query *query, sql_rel *rel, sql_exp *ls, sql_exp *rs, sql_exp *rs2, int type, int anti, int quantifier) { mvc *sql = query->sql; @@ -1759,45 +1799,7 @@ rel_compare_exp_(sql_query *query, sql_r else return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column in query results without an aggregate function"); } - if (rs->card <= CARD_ATOM && (exp_is_atom(rs) || exp_has_freevar(sql, rs) || exp_has_freevar(sql, ls)) && - (!rs2 || (rs2->card <= CARD_ATOM && (exp_is_atom(rs2) || exp_has_freevar(sql, rs2) { - if ((ls->card == rs->card && !rs2) || rel->processed) /* bin compare op */ - return rel_select(sql->sa, rel, e); - - if (/*is_semi(rel->op) ||*/ is_outerjoin(rel->op)) { - if ((is_left(rel->op) || is_full(rel->op)) && rel_find_exp(rel->l, ls)) { - rel_join_add_exp(sql->sa, rel, e); - return rel; - } else if ((is_right(rel->op) || is_full(rel->op)) && rel_find_exp(rel->r, ls)) {
MonetDB: default - Merged with Jun2020
Changeset: 23a37f635d2b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=23a37f635d2b Modified Files: gdk/gdk_hash.c gdk/gdk_storage.c geom/lib/libgeom.h geom/monetdb5/geom.c monetdb5/extras/rapi/rapi.c monetdb5/optimizer/opt_mergetable.c sql/backends/monet5/sql_statement.c sql/server/rel_optimizer.c sql/server/rel_rel.c sql/server/rel_unnest.c sql/server/sql_query.c sql/test/BugTracker-2008/Tests/select_not_wrong_result.SF-2080151.stable.out sql/test/subquery/Tests/subquery6.sql sql/test/subquery/Tests/subquery6.stable.out testing/Mtest.py.in tools/merovingian/daemon/handlers.c Branch: default Log Message: Merged with Jun2020 diffs (truncated from 575 to 300 lines): diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c --- a/gdk/gdk_hash.c +++ b/gdk/gdk_hash.c @@ -107,7 +107,11 @@ doHASHdestroy(BAT *b, Hash *hs) GDKunlink(BBPselectfarm(b->batRole, b->ttype, hashheap), BATDIR, BBP_physical(b->batCacheid), - "thash"); + "thashl"); + GDKunlink(BBPselectfarm(b->batRole, b->ttype, hashheap), + BATDIR, + BBP_physical(b->batCacheid), + "thashb"); } else if (hs) { bat p = VIEWtparent(b); BAT *hp = NULL; diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c --- a/gdk/gdk_storage.c +++ b/gdk/gdk_storage.c @@ -887,10 +887,10 @@ BATdelete(BAT *b) assert(bid > 0); if (loaded) { b = loaded; - HASHdestroy(b); - IMPSdestroy(b); - OIDXdestroy(b); } + HASHdestroy(b); + IMPSdestroy(b); + OIDXdestroy(b); if (b->batCopiedtodisk || (b->theap.storage != STORE_MEM)) { if (b->ttype != TYPE_void && HEAPdelete(>theap, o, "tail") != GDK_SUCCEED && diff --git a/monetdb5/optimizer/opt_mergetable.c b/monetdb5/optimizer/opt_mergetable.c --- a/monetdb5/optimizer/opt_mergetable.c +++ b/monetdb5/optimizer/opt_mergetable.c @@ -1959,9 +1959,12 @@ OPTmergetableImplementation(Client cntxt bailout = 1; } if (getModuleId(p) == algebraRef && - getFunctionId(p) == thetajoinRef ) { + getFunctionId(p) == thetajoinRef) { + assert(p->argc == 9); + if (p->argc == 9 && getVarConstant(mb,getArg(p,6)).val.ival == 6 /* op == '<>' */) { TRC_INFO(MAL_OPTIMIZER, "Mergetable bailout thetajoin ref\n"); bailout = 1; + } } if (isSample(p)) { bailout = 1; 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 @@ -2036,8 +2036,11 @@ stmt_semijoin(backend *be, stmt *op1, st if (op1->nr < 0 || op2->nr < 0) return NULL; - q = newStmt(mb, algebraRef, semijoinRef); - q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); + if (single) { + q = newStmt(mb, algebraRef, semijoinRef); + q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); + } else + q = newStmt(mb, algebraRef, intersectRef); q = pushArgument(mb, q, op1->nr); q = pushArgument(mb, q, op2->nr); if (lcand) @@ -2060,7 +2063,9 @@ stmt_semijoin(backend *be, stmt *op1, st s->op2 = op2; s->flag = cmp_equal; s->key = 0; - s->nrcols = 2; + s->nrcols = 1; + if (single) + s->nrcols = 2; s->nr = getDestVar(q); s->q = q; return s; diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -4101,7 +4101,7 @@ rel_merge_rse(mvc *sql, sql_rel *rel, in /* find in the list of expression an expression which uses e */ static sql_exp * -exp_uses_exp( list *exps, sql_exp *e) +exps_uses_exp( list *exps, sql_exp *e) { node *n; const char *rname = exp_relname(e); @@ -4246,7 +4246,7 @@ rel_push_aggr_down(mvc *sql, sql_rel *re for (n = ogbe->h; n; n = n->next) { sql_exp *e = n->data, *ne; - ne = exp_uses_exp( rel->exps, e); + ne = exps_uses_exp( rel->exps, e); if (!ne) continue; ne = list_find_exp( u->exps, ne); @@ -4780,11 +4780,11 @@ rel_push_join_down(mvc
MonetDB: default - Merged with Jun2020
Changeset: 9d161dd17da1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9d161dd17da1 Added Files: sql/test/Users/Tests/createUserRollback.SQL.py sql/test/Users/Tests/createUserRollback.stable.err sql/test/Users/Tests/createUserRollback.stable.out Modified Files: gdk/gdk_batop.c monetdb5/optimizer/opt_mergetable.c sql/backends/monet5/sql_statement.c sql/backends/monet5/sql_upgrades.c sql/test/Users/Tests/All 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/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: default Log Message: Merged with Jun2020 diffs (truncated from 424 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 @@ -496,6 +496,8 @@ BATappend(BAT *b, BAT *n, BAT *s, bool f BUN r; PROPrec *prop, *nprop; oid hseq = n->hseqbase; + char buf[64]; + lng t0 = 0; if (b == NULL || n == NULL || (cnt = BATcount(n)) == 0) { return GDK_SUCCEED; @@ -503,6 +505,11 @@ BATappend(BAT *b, BAT *n, BAT *s, bool f assert(b->batCacheid > 0); assert(b->theap.parentid == 0); + TRC_DEBUG_IF(ALGO) { + t0 = GDKusec(); + snprintf(buf, sizeof(buf), ALGOBATFMT, ALGOBATPAR(b)); + } + ALIGNapp(b, force, GDK_FAIL); if (ATOMstorage(ATOMtype(b->ttype)) != ATOMstorage(ATOMtype(n->ttype))) { @@ -518,7 +525,7 @@ BATappend(BAT *b, BAT *n, BAT *s, bool f cnt = canditer_init(, n, s); if (cnt == 0) { - return GDK_SUCCEED; + goto doreturn; } if (BUNlast(b) + cnt > BUN_MAX) { @@ -585,14 +592,14 @@ BATappend(BAT *b, BAT *n, BAT *s, bool f if (BATcount(b) == 0) BATtseqbase(b, n->tseqbase + ci.seq - hseq); BATsetcount(b, BATcount(b) + cnt); - return GDK_SUCCEED; + goto doreturn; } if ((BATcount(b) == 0 || is_oid_nil(b->tseqbase)) && n->ttype == TYPE_void && is_oid_nil(n->tseqbase)) { /* both b and n are void/nil */ BATtseqbase(b, oid_nil); BATsetcount(b, BATcount(b) + cnt); - return GDK_SUCCEED; + goto doreturn; } /* we need to materialize b; allocate enough capacity */ b->batCapacity = BATcount(b) + cnt; @@ -707,6 +714,13 @@ BATappend(BAT *b, BAT *n, BAT *s, bool f } if (b->thash) BATsetprop(b, GDK_NUNIQUE, TYPE_oid, &(oid){b->thash->nunique}); + + doreturn: + TRC_DEBUG(ALGO, "b=%s,n=" ALGOBATFMT ",s=" ALGOOPTBATFMT + " -> " ALGOBATFMT " (" LLFMT " usec)\n", + buf, ALGOBATPAR(n), ALGOOPTBATPAR(s), ALGOBATPAR(b), + GDKusec() - t0); + return GDK_SUCCEED; } diff --git a/monetdb5/optimizer/opt_mergetable.c b/monetdb5/optimizer/opt_mergetable.c --- a/monetdb5/optimizer/opt_mergetable.c +++ b/monetdb5/optimizer/opt_mergetable.c @@ -1958,6 +1958,11 @@ OPTmergetableImplementation(Client cntxt TRC_INFO(MAL_OPTIMIZER, "Mergetable bailout semijoin ref\n"); bailout = 1; } + if (getModuleId(p) == algebraRef && + getFunctionId(p) == thetajoinRef ) { + TRC_INFO(MAL_OPTIMIZER, "Mergetable bailout thetajoin ref\n"); + bailout = 1; + } if (isSample(p)) { bailout = 1; } diff --git
MonetDB: default - Merged with Jun2020
Changeset: 16d2366efcd8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=16d2366efcd8 Added Files: buildtools/selinux/ChangeLog.Jun2020 Modified Files: clients/Tests/exports.stable.out gdk/gdk_atoms.h gdk/gdk_utils.h sql/server/rel_dump.c sql/server/rel_exp.c sql/server/rel_select.c sql/server/rel_updates.c sql/test/BugTracker-2012/Tests/currenttime.Bug-2781.SQL.py sql/test/BugTracker-2012/Tests/currenttime.Bug-2781.stable.out 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/miscellaneous/Tests/simple_selects.sql sql/test/miscellaneous/Tests/simple_selects.stable.out sql/test/sys-schema/Tests/systemfunctions.stable.out sql/test/sys-schema/Tests/systemfunctions.stable.out.int128 Branch: default Log Message: Merged with Jun2020 diffs (truncated from 921 to 300 lines): diff --git a/buildtools/selinux/ChangeLog.Jun2020 b/buildtools/selinux/ChangeLog.Jun2020 new file mode 100644 --- /dev/null +++ b/buildtools/selinux/ChangeLog.Jun2020 @@ -0,0 +1,10 @@ +# ChangeLog file for selinux +# This file is updated with Maddlog + +* Wed May 6 2020 Sjoerd Mullender +- There was a problem with the MonetDB SELinux support on Fedora 32. + That is fixed in this release. In order to do a proper upgrade of + the package if you have already installed MonetDB-selinux on Fedora + 32, you may need to uninstall (dnf remove) the old package and then + install the new. + diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -14,7 +14,7 @@ char *ATOMformat(int id, const void *val int ATOMindex(const char *nme); size_t ATOMlen(int id, const void *v); str ATOMname(int id); -void *ATOMnil(int id); +void *ATOMnil(int id) __attribute__((__malloc__)); int ATOMprint(int id, const void *val, stream *fd); gdk_return BATappend(BAT *b, BAT *n, BAT *s, bool force) __attribute__((__warn_unused_result__)); void BATassertProps(BAT *b); @@ -299,8 +299,8 @@ gdk_return GDKsetenv(const char *name, c void GDKsetmallocsuccesscount(lng count); void GDKsetverbose(int verbosity); ssize_t GDKstrFromStr(unsigned char *restrict dst, const unsigned char *restrict src, ssize_t len); -str GDKstrdup(const char *s) __attribute__((__warn_unused_result__)); -str GDKstrndup(const char *s, size_t n) __attribute__((__warn_unused_result__)); +str GDKstrdup(const char *s) __attribute__((__malloc__)) __attribute__((__warn_unused_result__)); +str GDKstrndup(const char *s, size_t n) __attribute__((__malloc__)) __attribute__((__warn_unused_result__)); gdk_return GDKtracer_fill_comp_info(BAT *id, BAT *component, BAT *log_level); gdk_return GDKtracer_flush_buffer(void); const char *GDKtracer_get_component_level(const char *comp); diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h --- a/gdk/gdk_atoms.h +++ b/gdk/gdk_atoms.h @@ -68,7 +68,8 @@ gdk_export int ATOMindex(const char *nme gdk_export str ATOMname(int id); gdk_export size_t ATOMlen(int id, const void *v); -gdk_export void *ATOMnil(int id); +gdk_export void *ATOMnil(int id) + __attribute__((__malloc__)); gdk_export int ATOMprint(int id, const void *val, stream *fd); gdk_export char *ATOMformat(int id, const void *val); diff --git a/gdk/gdk_utils.h b/gdk/gdk_utils.h --- a/gdk/gdk_utils.h +++ b/gdk/gdk_utils.h @@ -93,8 +93,10 @@ gdk_export void *GDKrealloc(void *pold, __attribute__((__warn_unused_result__)); gdk_export void GDKfree(void *blk); gdk_export str GDKstrdup(const char *s) + __attribute__((__malloc__)) __attribute__((__warn_unused_result__)); gdk_export str GDKstrndup(const char *s, size_t n) + __attribute__((__malloc__)) __attribute__((__warn_unused_result__)); gdk_export void MT_init(void); /* init the package. */ diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c --- a/sql/server/rel_dump.c +++ b/sql/server/rel_dump.c @@ -771,7 +771,8 @@ read_prop( mvc *sql, sql_exp *exp, char return sql_error(sql, -1, SQLSTATE(42000) "Schema %s missing\n", sname); if (!find_prop(exp->p, PROP_JOINIDX)) { p = exp->p = prop_create(sql->sa, PROP_JOINIDX, exp->p); - p->value = mvc_bind_idx(sql, s, iname); + if (!(p->value = mvc_bind_idx(sql, s, iname))) + return sql_error(sql, -1, SQLSTATE(42000) "Index %s missing\n", iname); } r[*pos] = old; skipWS(r,pos); @@ -873,7 +874,7 @@ exp_read(mvc *sql, sql_rel *lrel, sql_re if (!exp && rrel) exp = rel_bind_column2(sql, rrel, tname, cname, 0); } else if (!exp) { - exp =
MonetDB: default - Merged with Jun2020
Changeset: 23a00ecb5e48 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=23a00ecb5e48 Added Files: sql/test/subquery/Tests/subquery6.sql sql/test/subquery/Tests/subquery6.stable.err sql/test/subquery/Tests/subquery6.stable.out Modified Files: sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_execute.c sql/backends/monet5/sql_user.c sql/server/rel_dump.c sql/server/rel_optimizer.c sql/server/rel_rel.h sql/server/rel_select.c sql/server/rel_semantic.c sql/server/rel_updates.c sql/storage/sql_storage.h sql/storage/store.c sql/test/subquery/Tests/All Branch: default Log Message: Merged with Jun2020 diffs (truncated from 747 to 300 lines): 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 @@ -1441,7 +1441,7 @@ rel_parse_value(backend *be, char *query *m = o; m->session->status = status; } else { - int label = m->label; + unsigned int label = m->label; while (m->topvars > o.topvars) { if (m->vars[--m->topvars].name) @@ -3632,7 +3632,7 @@ sql_parse(backend *be, sql_allocator *sa sa_destroy(m->sa); m->sym = NULL; { - int label = m->label; + unsigned int label = m->label; int status = m->session->status; int sizevars = m->sizevars, topvars = m->topvars; sql_var *vars = m->vars; @@ -4738,7 +4738,7 @@ cascade_updates(backend *be, sql_table * if (i->key) { if (!(sql->cascade_action && list_find_id(sql->cascade_action, i->key->base.id))) { sql_key *k = i->key; - int *local_id = SA_NEW(sql->sa, int); + sqlid *local_id = SA_NEW(sql->sa, sqlid); if (!sql->cascade_action) sql->cascade_action = sa_list(sql->sa); *local_id = i->key->base.id; @@ -5216,7 +5216,7 @@ sql_delete_keys(backend *be, sql_table * if (k->type == pkey || k->type == ukey) { if (!(sql->cascade_action && list_find_id(sql->cascade_action, k->base.id))) { - int *local_id = SA_NEW(sql->sa, int); + sqlid *local_id = SA_NEW(sql->sa, sqlid); if (!sql->cascade_action) sql->cascade_action = sa_list(sql->sa); diff --git a/sql/backends/monet5/sql_execute.c b/sql/backends/monet5/sql_execute.c --- a/sql/backends/monet5/sql_execute.c +++ b/sql/backends/monet5/sql_execute.c @@ -448,7 +448,8 @@ SQLescapeString(str s) str SQLstatementIntern(Client c, str *expr, str nme, bit execute, bit output, res_table **result) { - int status = 0, err = 0, oldvtop, oldstop = 1, inited = 0, label, ac, sizevars, topvars; + int status = 0, err = 0, oldvtop, oldstop = 1, inited = 0, ac, sizevars, topvars; + unsigned int label; mvc *o, *m; sql_var *vars; buffer *b; diff --git a/sql/backends/monet5/sql_user.c b/sql/backends/monet5/sql_user.c --- a/sql/backends/monet5/sql_user.c +++ b/sql/backends/monet5/sql_user.c @@ -542,9 +542,9 @@ monet5_user_set_def_schema(mvc *m, oid u rid = table_funcs.column_find_row(m->session->tr, auths_name, username, NULL); if (!is_oid_nil(rid)) { sql_column *auths_id = find_sql_column(auths, "id"); - int id; + sqlid id; p = table_funcs.column_find_value(m->session->tr, auths_id, rid); - id = *(int *) p; + id = *(sqlid *) p; _DELETE(p); m->user_id = m->role_id = id; diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c --- a/sql/server/rel_dump.c +++ b/sql/server/rel_dump.c @@ -340,9 +340,8 @@ op2string(operator_type op) case op_delete: case op_truncate: return "modify op"; - default: - return "unknown"; } + return "unknown"; } static int @@ -838,7 +837,7 @@ read_exps(mvc *sql, sql_rel *lrel, sql_r static sql_exp* exp_read(mvc *sql, sql_rel *lrel, sql_rel *rrel, list *pexps, char *r, int *pos, int grp) { - int f = -1, not = 1, old, d=0, s=0, unique = 0, no_nils = 0, quote = 0; + int f = -1, not = 1, old, d=0, s=0, unique = 0, no_nils = 0, quote = 0, zero_if_empty = 0; char *tname = NULL, *cname = NULL, *var_cname = NULL, *e, *b = r + *pos, *st; sql_exp *exp = NULL; list *exps = NULL; @@ -894,7 +893,7 @@ exp_read(mvc *sql, sql_rel *lrel, sql_re } if
MonetDB: default - Merged with Jun2020
Changeset: f0b559953113 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f0b559953113 Modified Files: clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 clients/Tests/exports.stable.out configure.ag gdk/ChangeLog.Jun2020 gdk/gdk.h gdk/gdk_firstn.c gdk/gdk_join.c monetdb5/ChangeLog.Jun2020 monetdb5/modules/kernel/algebra.c monetdb5/modules/kernel/algebra.h monetdb5/modules/kernel/algebra.mal sql/backends/monet5/sql.c sql/backends/monet5/sql_statement.c sql/server/rel_distribute.c sql/server/rel_exp.c sql/server/rel_optimizer.c sql/server/rel_partition.c sql/server/rel_propagate.c sql/server/rel_rel.c sql/server/sql_env.c sql/server/sql_env.h sql/server/sql_partition.c sql/storage/bat/bat_logger.c sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.stable.out sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.stable.out.Windows sql/test/Dependencies/Tests/Dependencies.stable.out sql/test/Dependencies/Tests/Dependencies.stable.out.int128 sql/test/Tests/truncate-statements-extra.stable.out 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/miscellaneous/Tests/simple_selects.sql sql/test/miscellaneous/Tests/simple_selects.stable.err Branch: default Log Message: Merged with Jun2020 diffs (truncated from 1940 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 @@ -591,7 +591,7 @@ stdout of test 'MAL-signatures` in direc [ "algebra", "ilikejoin","command algebra.ilikejoin(l:bat[:str], r:bat[:str], esc:str, sl:bat[:oid], sr:bat[:oid], nil_matches:bit, estimate:lng) (X_0:bat[:oid], X_1:bat[:oid]) ", "ILIKEjoin;", "Join the string bat L with the pattern bat R\nwith optional candidate lists SL and SR using pattern escape string ESC\nand doing a case insensitive match.\nThe result is two aligned bats with oids of matching rows."] [ "algebra", "ilikeselect", "command algebra.ilikeselect(b:bat[:str], cand:bat[:oid], pat:str, esc:str, anti:bit):bat[:oid] ", "PCRElikeselect1;", "" ] [ "algebra", "ilikeselect", "command algebra.ilikeselect(b:bat[:str], cand:bat[:oid], pat:str, anti:bit):bat[:oid] ", "PCRElikeselect4;", "" ] -[ "algebra", "intersect","command algebra.intersect(l:bat[:any_1], r:bat[:any_1], sl:bat[:oid], sr:bat[:oid], nil_matches:bit, estimate:lng):bat[:oid] ","ALGintersect;","Intersection of l and r with candidate lists (i.e. half of semi-join)" ] +[ "algebra", "intersect","command algebra.intersect(l:bat[:any_1], r:bat[:any_1], sl:bat[:oid], sr:bat[:oid], nil_matches:bit, max_one:bit, estimate:lng):bat[:oid] ", "ALGintersect;","Intersection of l and r with candidate lists (i.e. half of semi-join)" ] [ "algebra", "join", "command algebra.join(l:bat[:any_1], r:bat[:any_1], sl:bat[:oid], sr:bat[:oid], nil_matches:bit, estimate:lng):bat[:oid] ", "ALGjoin1;","Join; only produce left output"] [ "algebra", "join", "command algebra.join(l:bat[:any_1], r:bat[:any_1], sl:bat[:oid], sr:bat[:oid], nil_matches:bit, estimate:lng) (X_0:bat[:oid], X_1:bat[:oid]) ","ALGjoin;", "Join" ] [ "algebra", "leftjoin", "command algebra.leftjoin(l:bat[:any_1], r:bat[:any_1], sl:bat[:oid], sr:bat[:oid], nil_matches:bit, estimate:lng):bat[:oid] ", "ALGleftjoin1;","Left join with candidate lists; only produce left output" ] @@ -620,7 +620,7 @@ stdout of test 'MAL-signatures` in direc [ "algebra", "select", "command algebra.select(b:bat[:any_1], s:bat[:oid], low:any_1, high:any_1, li:bit, hi:bit, anti:bit):bat[:oid] ", "ALGselect2;", "Select all head values of the first input BAT for which the tail value\n\tis in range and for which the head value occurs in the tail of the\n\tsecond input BAT.\n\tThe first input is a dense-headed BAT, the second input is a\n\tdense-headed BAT with sorted tail, output is a dense-headed BAT\n\twith in the tail the head value of the input BAT for which the\n\ttail value is between the values low and high (inclusive if li\n\trespectively hi is set). The output BAT is sorted on the tail\n\tvalue. If low or high is nil, the boundary is not considered\n\t(effectively - and + infinity). If anti is set, the result is the\n\tcomplement. Nil values in the tail are never matched, unless\n\tlow=nil, high=nil, li=1, hi=1, anti=0. All non-nil values are\n\treturned if low=nil, high=nil, and li, hi are not both 1, or
MonetDB: default - Merged with Jun2020
Changeset: 20ef7e69f853 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=20ef7e69f853 Modified Files: MonetDB.spec common/stream/stream.h common/utils/mstring.h sql/include/sql_relation.h sql/server/rel_select.c sql/server/rel_unnest.c sql/test/BugTracker-2017/Tests/groupby_assertion.Bug-6338.stable.err sql/test/mergetables/Tests/sqlsmith-exists.stable.out sql/test/subquery/Tests/subquery5.sql sql/test/subquery/Tests/subquery5.stable.err sql/test/subquery/Tests/subquery5.stable.out tools/merovingian/daemon/forkmserver.c Branch: default Log Message: Merged with Jun2020 diffs (truncated from 412 to 300 lines): diff --git a/MonetDB.spec b/MonetDB.spec --- a/MonetDB.spec +++ b/MonetDB.spec @@ -649,7 +649,9 @@ Recommends: %{name}-SQL-server5-hugeint% Suggests: %{name}-client%{?_isa} = %{version}-%{release} %endif %if %{?rhel:0}%{!?rhel:1} || 0%{?rhel} >= 7 -%systemd_requires +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd %endif %description SQL-server5 diff --git a/common/stream/stream.h b/common/stream/stream.h --- a/common/stream/stream.h +++ b/common/stream/stream.h @@ -54,18 +54,11 @@ typedef __int128_t hge; /* Defines to help the compiler check printf-style format arguments. * These defines are also in our config.h, but we repeat them here so * that we don't need that for this file.*/ -#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) +#ifndef __GNUC__ /* This feature is available in gcc versions 2.5 and later. */ # ifndef __attribute__ # define __attribute__(Spec) /* empty */ # endif -#else -/* The __-protected variants of `format' and `printf' attributes are - * accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ -# if !defined(__format__) && (__GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)) -# define __format__ format -# define __printf__ printf -# endif #endif #if !defined(_MSC_VER) && !defined(_In_z_) # define _In_z_ diff --git a/common/utils/mstring.h b/common/utils/mstring.h --- a/common/utils/mstring.h +++ b/common/utils/mstring.h @@ -12,7 +12,8 @@ #include /* va_list etc. */ #include /* strlen */ -#ifdef __GNUC__ +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)) +/* not on CentOS 6 (GCC 4.4.7) */ #define GCC_Pragma(pragma) _Pragma(pragma) #else #define GCC_Pragma(pragma) diff --git a/sql/include/sql_relation.h b/sql/include/sql_relation.h --- a/sql/include/sql_relation.h +++ b/sql/include/sql_relation.h @@ -246,6 +246,9 @@ typedef enum operator_type { #define is_dependent(rel) ((rel)->dependent) #define set_dependent(rel) (rel)->dependent = 1 #define reset_dependent(rel) (rel)->dependent = 0 +#define is_outer(rel) ((rel)->outer) +#define set_outer(rel) (rel)->outer = 1 +#define reset_outer(rel) (rel)->outer = 0 #define is_freevar(e) ((e)->freevar) #define set_freevar(e,level) (e)->freevar = level+1 @@ -267,6 +270,7 @@ typedef struct relation { dependent:1, /* dependent join */ distinct:1, processed:1, /* fully processed or still in the process of building */ +outer:1, /* used as outer (ungrouped) */ grouped:1, /* groupby processed all the group by exps */ subquery:1;/* is this part a subquery, this is needed for proper name binding */ void *p;/* properties for the optimizer, distribution */ diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -1197,6 +1197,8 @@ rel_column_ref(sql_query *query, sql_rel else exp->card = CARD_ATOM; set_freevar(exp, i); + if (!is_sql_aggr(f) && !outer->grouped) + set_outer(outer); } if (exp && outer && is_join(outer->op)) set_dependent(outer); @@ -1263,6 +1265,8 @@ rel_column_ref(sql_query *query, sql_rel else exp->card = CARD_ATOM; set_freevar(exp, i); + if (!is_sql_aggr(f) && !outer->grouped) + set_outer(outer); } if (exp && outer && is_join(outer->op)) set_dependent(outer); @@ -3475,6 +3479,8 @@ static sql_exp * sql_exp *lu = query_outer_last_used(query, all_freevar-1); return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: subquery uses ungrouped column \"%s.%s\" from outer query",
MonetDB: default - Merged with Jun2020
Changeset: aec05a862c85 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=aec05a862c85 Modified Files: MonetDB.spec buildtools/conf/monetdbd.conf buildtools/selinux/monetdb.fc buildtools/selinux/monetdb.te clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 clients/Tests/exports.stable.out debian/control debian/monetdb5-server.dirs debian/monetdb5-server.postinst debian/monetdb5-sql.install debian/monetdb5-sql.postinst gdk/gdk_system.h gdk/gdk_tracer.c gdk/gdk_tracer.h gdk/gdk_utils.c monetdb5/modules/atoms/mtime.c monetdb5/modules/atoms/mtime.mal monetdb5/modules/mal/mdb.c rpm.mk.in sql/backends/monet5/sql_statement.c sql/common/sql_types.c sql/server/rel_optimizer.c sql/server/rel_propagate.c sql/server/rel_updates.c sql/test/BugDay_2005-11-09_2.9.3/Tests/date_functions.SF-967145.stable.out sql/test/BugTracker-2016/Tests/date_calculation_and_comparison_wrong_results.Bug-3940.sql sql/test/BugTracker-2016/Tests/date_calculation_and_comparison_wrong_results.Bug-3940.stable.out sql/test/Tests/hot-snapshot.py sql/test/VOC/Tests/median.Bug-3096.stable.out sql/test/bugs/Tests/default_with_cast.SF-1334486.stable.out 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/pg_regress/Tests/date.stable.out sql/test/sys-schema/Tests/systemfunctions.stable.out sql/test/sys-schema/Tests/systemfunctions.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 tools/merovingian/ChangeLog.Jun2020 Branch: default Log Message: Merged with Jun2020 diffs (truncated from 1456 to 300 lines): diff --git a/MonetDB.spec b/MonetDB.spec --- a/MonetDB.spec +++ b/MonetDB.spec @@ -107,11 +107,14 @@ URL: https://www.monetdb.org/ BugURL: https://bugs.monetdb.org/ Source: https://www.monetdb.org/downloads/sources/Nov2019-SP3/%{name}-%{version}.tar.bz2 -# we need systemd for the _unitdir macro to exist -# we need checkpolicy and selinux-policy-devel for the SELinux policy +# The Fedora packaging document says we need systemd-rpm-macros for +# the _unitdir and _tmpfilesdir macros to exist; however on RHEL 7 +# that doesn't exist and we need systemd, so instead we just require +# the macro file that contains the definitions. +# We need checkpolicy and selinux-policy-devel for the SELinux policy. %if %{?rhel:0}%{!?rhel:1} || 0%{?rhel} >= 7 # RHEL >= 7, and all current Fedora -BuildRequires: systemd +BuildRequires: /usr/lib/rpm/macros.d/macros.systemd BuildRequires: checkpolicy BuildRequires: selinux-policy-devel BuildRequires: hardlink @@ -519,15 +522,27 @@ package if you want to use the MonetDB d to use the SQL front end, you also need %{name}-SQL-server5. %pre -n MonetDB5-server -getent group monetdb >/dev/null || groupadd -r monetdb -getent passwd monetdb >/dev/null || \ -useradd -r -g monetdb -d %{_localstatedir}/MonetDB -s /sbin/nologin \ - -c "MonetDB Server" monetdb +getent group monetdb >/dev/null || groupadd --system monetdb +if getent passwd monetdb >/dev/null; then +case $(getent passwd monetdb | cut -d: -f6) in +%{_localstatedir}/MonetDB) # old value + # change home directory, but not using usermod + # usermod requires there not to be any running processes owned by the user + EDITOR='sed -i "/^monetdb:/s|:%{_localstatedir}/MonetDB:|:%{_localstatedir}/lib/monetdb:|"' + unset VISUAL +
MonetDB: default - Merged with Jun2020
Changeset: 2041dbb13d2f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2041dbb13d2f Modified Files: monetdb5/modules/atoms/json.c sql/server/rel_exp.c sql/server/rel_rel.c sql/test/json/Tests/All sql/test/json/Tests/jsonvalidity.Bug-3753.sql sql/test/json/Tests/jsonvalidity.Bug-3753.stable.out sql/test/sys-schema/Tests/systemfunctions.stable.out sql/test/sys-schema/Tests/systemfunctions.stable.out.int128 sql/test/testdb/Tests/dump-nogeom.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 428 to 300 lines): diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c --- a/monetdb5/modules/atoms/json.c +++ b/monetdb5/modules/atoms/json.c @@ -769,13 +769,13 @@ JSONstringParser(const char *j, const ch static bool JSONintegerParser(const char *j, const char **next) { - if (*j == '-') -j++; + if (*j == '-') + j++; - // skipblancs(j); - if (!isdigit((unsigned char)*j)) { -*next = j; -return false; + // skipblancs(j); + if (!isdigit((unsigned char)*j)) { + *next = j; + return false; } if (*j == '0') { @@ -784,7 +784,7 @@ JSONintegerParser(const char *j, const c } for(; *j; j++) - if (!(isdigit((unsigned char) *j) && *j != '0')) + if (!(isdigit((unsigned char) *j))) break; *next = j; diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c --- a/sql/server/rel_exp.c +++ b/sql/server/rel_exp.c @@ -2274,16 +2274,17 @@ exps_alias(mvc *sql, list *exps) } list * -exps_copy( mvc *sql, list *exps) +exps_copy(mvc *sql, list *exps) { - node *n; list *nl; - if (!exps) - return exps; + if (THRhighwater()) + return sql_error(sql, 10, SQLSTATE(42000) "Query too complex: running out of stack space"); + if (!exps) + return NULL; nl = new_exp_list(sql->sa); - for(n = exps->h; n; n = n->next) { + for (node *n = exps->h; n; n = n->next) { sql_exp *arg = n->data; arg = exp_copy(sql, arg); @@ -2295,10 +2296,15 @@ exps_copy( mvc *sql, list *exps) } sql_exp * -exp_copy( mvc *sql, sql_exp * e) +exp_copy(mvc *sql, sql_exp * e) { sql_exp *l, *r, *r2, *ne = NULL; + if (THRhighwater()) + return sql_error(sql, 10, SQLSTATE(42000) "Query too complex: running out of stack space"); + + if (!e) + return NULL; switch(e->type){ case e_column: ne = exp_column(sql->sa, e->l, e->r, exp_subtype(e), e->card, has_nil(e), is_intern(e)); @@ -2308,51 +2314,39 @@ exp_copy( mvc *sql, sql_exp * e) if (e->flag == cmp_or || e->flag == cmp_filter) { list *l = exps_copy(sql, e->l); list *r = exps_copy(sql, e->r); - if (l && r) { - if (e->flag == cmp_filter) - ne = exp_filter(sql->sa, l, r, e->f, is_anti(e)); - else - ne = exp_or(sql->sa, l, r, is_anti(e)); - } + + if (e->flag == cmp_filter) + ne = exp_filter(sql->sa, l, r, e->f, is_anti(e)); + else + ne = exp_or(sql->sa, l, r, is_anti(e)); } else if (e->flag == cmp_in || e->flag == cmp_notin) { sql_exp *l = exp_copy(sql, e->l); list *r = exps_copy(sql, e->r); - if (l && r) - ne = exp_in(sql->sa, l, r, e->flag); + ne = exp_in(sql->sa, l, r, e->flag); } else { l = exp_copy(sql, e->l); r = exp_copy(sql, e->r); if (e->f) { r2 = exp_copy(sql, e->f); - if (l && r && r2) - ne = exp_compare2(sql->sa, l, r, r2, e->flag); - } else if (l && r) { + ne = exp_compare2(sql->sa, l, r, r2, e->flag); + } else { ne = exp_compare(sql->sa, l, r, e->flag); } } break; case e_convert: - l = exp_copy(sql, e->l); - if (l) - ne = exp_convert(sql->sa, l, exp_fromtype(e), exp_totype(e)); + ne = exp_convert(sql->sa, exp_copy(sql, e->l), exp_fromtype(e), exp_totype(e)); break; case e_aggr: case e_func: { - list *l = e->l, *nl = NULL; + list *l
MonetDB: default - Merged with Jun2020
Changeset: f3fa4abc4ee8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f3fa4abc4ee8 Modified Files: MonetDB.spec NT/Makefile NT/rules.msc NT/winconfig.py buildtools/autogen/autogen/am.py buildtools/autogen/autogen/msc.py debian/changelog monetdb5/optimizer/opt_support.c sql/ChangeLog.Jun2020 sql/backends/monet5/sql_upgrades.c sql/scripts/51_sys_schema_extension.sql sql/server/rel_select.c sql/server/rel_updates.c sql/server/sql_parser.y sql/server/sql_scan.c sql/server/sql_tokens.h sql/test/BugTracker-2015/Tests/project_rewrite.Bug-3693.sql 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/subquery/Tests/subquery5.sql sql/test/subquery/Tests/subquery5.stable.err testing/Mtest.py.in Branch: default Log Message: Merged with Jun2020 diffs (truncated from 654 to 300 lines): diff --git a/MonetDB.spec b/MonetDB.spec --- a/MonetDB.spec +++ b/MonetDB.spec @@ -5062,20 +5062,20 @@ fi * Fri May 13 2011 Sjoerd Mullender - 11.3.3-20110517 - gdk: Fixed a bug where large files (> 2GB) didn't always get deleted on -Windows. + Windows. * Wed May 11 2011 Fabian Groffen - 11.3.3-20110517 - java: Insertion via PreparedStatement and retrieval via ResultSet of timestamp -and time fields with and without timezones was improved to better -respect timezones, as partly indicated in bug #2781. + and time fields with and without timezones was improved to better + respect timezones, as partly indicated in bug #2781. * Wed May 11 2011 Sjoerd Mullender - 11.3.3-20110517 - monetdb5: Fixed a bug in conversion from string to the URL type. The bug was -an incorrect call to free(). + an incorrect call to free(). * Wed Apr 27 2011 Sjoerd Mullender - 11.3.3-20110517 - geom: Fixed various problems so that now all our tests work correctly on -all our testing platforms. + all our testing platforms. * Thu Apr 21 2011 Sjoerd Mullender - 11.3.1-20110421 - Rebuilt. diff --git a/NT/Makefile b/NT/Makefile --- a/NT/Makefile +++ b/NT/Makefile @@ -64,7 +64,6 @@ targetdirs: if not exist "$(libexecdir)"$(MKDIR) "$(libexecdir)" if not exist "$(datadir)" $(MKDIR) "$(datadir)" if not exist "$(sysconfdir)"$(MKDIR) "$(sysconfdir)" - if not exist "$(sharedstatedir)"$(MKDIR) "$(sharedstatedir)" if not exist "$(localstatedir)" $(MKDIR) "$(localstatedir)" if not exist "$(libdir)"$(MKDIR) "$(libdir)" if not exist "$(infodir)" $(MKDIR) "$(infodir)" diff --git a/NT/rules.msc b/NT/rules.msc --- a/NT/rules.msc +++ b/NT/rules.msc @@ -218,7 +218,6 @@ sbindir = $(exec_prefix)\sbin libexecdir = $(exec_prefix)\libexec datadir = $(prefix)\share sysconfdir = $(prefix)\etc -sharedstatedir = $(prefix)\com localstatedir = $(prefix)\var libdir = $(exec_prefix)\lib infodir = $(prefix)\info diff --git a/NT/winconfig.py b/NT/winconfig.py --- a/NT/winconfig.py +++ b/NT/winconfig.py @@ -18,7 +18,6 @@ subs = [("@exec_prefix@", r'%prefix%'), ("@datadir@", r'%prefix%\share'), ("@datarootdir@", r'%prefix%\share'), ("@sysconfdir@", r'%prefix%\etc'), -("@sharedstatedir@", r'%prefix%\com'), ("@localstatedir@", r'%prefix%\var'), ("@libdir@", r'%exec_prefix%\lib'), ("@infodir@", r'%prefix%\info'), diff --git a/buildtools/autogen/autogen/am.py b/buildtools/autogen/autogen/am.py --- a/buildtools/autogen/autogen/am.py +++ b/buildtools/autogen/autogen/am.py @@ -853,7 +853,7 @@ def am_translate_dir(path, am): 'libdir', 'libexecdir', 'localstatedir', 'mandir', 'oldincludedir', 'pkgbindir', 'pkgdatadir', 'pkgincludedir', 'pkglibdir', 'pkglocalstatedir', 'pkgsysconfdir', 'sbindir', - 'sharedstatedir', 'srcdir', 'sysconfdir', 'top_builddir', + 'srcdir', 'sysconfdir', 'top_builddir', 'top_srcdir', 'prefix'): dir = "$("+dir+")" dir = dir + rest diff --git a/buildtools/autogen/autogen/msc.py b/buildtools/autogen/autogen/msc.py --- a/buildtools/autogen/autogen/msc.py +++ b/buildtools/autogen/autogen/msc.py @@ -147,7 +147,7 @@ def msc_translate_dir(path, msc): 'libdir', 'libexecdir', 'localstatedir', 'mandir', 'oldincludedir', 'pkgbindir', 'pkgdatadir', 'pkgincludedir', 'pkglibdir', 'pkglocalstatedir', 'pkgsysconfdir', 'sbindir', - 'sharedstatedir', 'srcdir', 'sysconfdir', 'top_builddir', + 'srcdir', 'sysconfdir', 'top_builddir', 'top_srcdir', 'prefix'): dir = "$("+dir+")" if rest: diff --git a/debian/changelog b/debian/changelog --- a/debian/changelog +++
MonetDB: default - Merged with Jun2020
Changeset: f39eafbd0b4a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f39eafbd0b4a Modified Files: gdk/gdk.h gdk/gdk_bat.c gdk/gdk_bbp.c gdk/gdk_hash.c gdk/gdk_imprints.c gdk/gdk_orderidx.c gdk/gdk_storage.c gdk/gdk_system.c gdk/gdk_system.h gdk/gdk_utils.c monetdb5/mal/mal_client.c monetdb5/mal/mal_dataflow.c monetdb5/modules/mal/mal_mapi.c monetdb5/modules/mal/tablet.c sql/backends/monet5/mal_backend.c sql/backends/monet5/sql_gencode.c sql/backends/monet5/sql_statement.c sql/common/sql_types.c sql/server/rel_exp.c sql/server/rel_select.c sql/server/rel_unnest.c sql/server/sql_atom.c sql/server/sql_partition.c sql/server/sql_query.c sql/server/sql_semantic.c sql/storage/bat/bat_storage.c sql/storage/sql_storage.h sql/storage/store.c sql/test/Tests/hot-snapshot.py sql/test/miscellaneous/Tests/simple_selects.sql sql/test/miscellaneous/Tests/simple_selects.stable.err sql/test/subquery/Tests/subquery5.sql sql/test/subquery/Tests/subquery5.stable.err sql/test/subquery/Tests/subquery5.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 879 to 300 lines): diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -1709,7 +1709,7 @@ typedef struct threadStruct { * into this array + 1 (0 is * invalid) */ ATOMIC_TYPE pid;/* thread id, 0 = unallocated */ - char name[16]; + char name[MT_NAME_LEN]; void *data[THREADDATA]; uintptr_t sp; } *Thread; diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -121,7 +121,7 @@ BATcreatedesc(oid hseq, int tt, bool hea bn->tvheap->parentid = bn->batCacheid; bn->tvheap->farmid = BBPselectfarm(role, bn->ttype, varheap); } - char name[16]; + char name[MT_NAME_LEN]; snprintf(name, sizeof(name), "BATlock%d", bn->batCacheid); /* fits */ MT_lock_init(>batIdxLock, name); bn->batDirtydesc = true; diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -910,7 +910,7 @@ BBPreadEntries(FILE *fp, unsigned bbpver bn->batCount = (BUN) count; bn->batInserted = bn->batCount; bn->batCapacity = (BUN) capacity; - char name[16]; + char name[MT_NAME_LEN]; snprintf(name, sizeof(name), "BATlock%d", bn->batCacheid); /* fits */ MT_lock_init(>batIdxLock, name); diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c --- a/gdk/gdk_hash.c +++ b/gdk/gdk_hash.c @@ -957,7 +957,7 @@ BAThash(BAT *b) if (BBP_status(b->batCacheid) & BBPEXISTING && !b->theap.dirty && !GDKinmemory()) { MT_Id tid; BBPfix(b->batCacheid); - char name[16]; + char name[MT_NAME_LEN]; snprintf(name, sizeof(name), "hashsync%d", b->batCacheid); MT_lock_unset(>batIdxLock); if (MT_create_thread(, BAThashsync, b, diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c --- a/gdk/gdk_imprints.c +++ b/gdk/gdk_imprints.c @@ -534,7 +534,7 @@ BATimprints(BAT *b) !GDKinmemory()) { MT_Id tid; BBPfix(b->batCacheid); - char name[16]; + char name[MT_NAME_LEN]; snprintf(name, sizeof(name), "impssync%d", b->batCacheid); if (MT_create_thread(, BATimpsync, b, MT_THR_DETACHED, name) < 0) diff --git a/gdk/gdk_orderidx.c b/gdk/gdk_orderidx.c --- a/gdk/gdk_orderidx.c +++ b/gdk/gdk_orderidx.c @@ -169,7 +169,7 @@ persistOIDX(BAT *b) !GDKinmemory()) { MT_Id tid; BBPfix(b->batCacheid); - char name[16]; + char name[MT_NAME_LEN]; snprintf(name, sizeof(name), "oidxsync%d", b->batCacheid); if (MT_create_thread(, BATidxsync, b, MT_THR_DETACHED, name) < 0) @@ -479,7 +479,7 @@ GDKmergeidx(BAT *b, BAT**a, int n_ar) b->batInserted == b->batCount) { MT_Id tid; BBPfix(b->batCacheid); - char name[16]; + char name[MT_NAME_LEN]; snprintf(name, sizeof(name), "oidxsync%d", b->batCacheid); if (MT_create_thread(, BATidxsync, b, MT_THR_DETACHED, name) < 0) diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c --- a/gdk/gdk_storage.c +++ b/gdk/gdk_storage.c
MonetDB: default - Merged with Jun2020
Changeset: bcc9a1485c4b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bcc9a1485c4b Modified Files: sql/server/rel_select.c sql/server/rel_unnest.c sql/server/rel_unnest.h sql/test/Tests/hot-snapshot.py sql/test/subquery/Tests/subquery3.stable.err sql/test/subquery/Tests/subquery5.stable.err Branch: default Log Message: Merged with Jun2020 diffs (truncated from 329 to 300 lines): diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -1191,7 +1191,7 @@ rel_column_ref(sql_query *query, sql_rel if (exp) break; } - if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && (!is_sql_aggr(f) || is_sql_farg(f))) + if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && !is_sql_aggr(f)) return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column '%s' in query results without an aggregate function", name); if (exp && outer && !is_sql_aggr(f)) { if (query_outer_used_exp( query, i, exp, f)) { @@ -1257,7 +1257,7 @@ rel_column_ref(sql_query *query, sql_rel if (exp) break; } - if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && (!is_sql_aggr(f) || is_sql_farg(f))) + if (exp && outer && outer->card <= CARD_AGGR && exp->card > CARD_AGGR && !is_sql_aggr(f)) return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column '%s.%s' in query results without an aggregate function", tname, cname); if (exp && outer && !is_sql_aggr(f)) { if (query_outer_used_exp( query, i, exp, f)) { @@ -3349,14 +3349,16 @@ static sql_exp * exps = sa_list(sql->sa); if (args && args->data.sym) { - int ungrouped_col = -1, i, all_aggr = query_has_outer(query); + int i, all_aggr = query_has_outer(query); + bool found_nested_aggr = false; + list *ungrouped_cols = NULL; + all_freevar = 1; - bool found_nested_aggr = false; for (i = 0; args && args->data.sym; args = args->next, i++) { int base = (!groupby || !is_project(groupby->op) || is_base(groupby->op) || is_processed(groupby)); - bool found_one = false; - sql_rel *outer = NULL, *gl = base?groupby:groupby->l, *ogl = gl; /* handle case of subqueries without correlation */ - sql_exp *e = rel_value_exp(query, , args->data.sym, (f | sql_aggr)& ~sql_farg, ek), *a = NULL; + sql_rel *gl = base?groupby:groupby->l, *ogl = gl; /* handle case of subqueries without correlation */ + sql_exp *e = rel_value_exp(query, , args->data.sym, (f | sql_aggr)& ~sql_farg, ek); + bool found_one_freevar = false; has_args = true; if (gl && gl != ogl) { @@ -3384,38 +3386,15 @@ static sql_exp * return e; } - if (is_freevar(e) && e->type == e_column) { - if ((outer = query_fetch_outer(query, is_freevar(e)-1))) { - if ((a = rel_find_exp(outer, e)) && is_aggr(a->type)) - return sql_error(sql, 05, SQLSTATE(42000) "SELECT: aggregate function calls cannot be nested"); - } - } - - if (all_aggr) { - /* get expression from outer */ - int aggr = 0; - if (a) - aggr = is_aggr(a->type); - else if (outer && outer->grouped) - ungrouped_col = i; - all_aggr &= aggr; - } else { - all_aggr &= (exp_card(e) <= CARD_AGGR && !exp_is_atom(e) && is_aggr(e->type) && !is_func(e->type) && (!groupby || !is_groupby(groupby->op) || !groupby->r || !exps_find_exp(groupby->r, e))); - } - all_freevar &= (exp_only_freevar(query, e, _one, _nested_aggr) && found_one); + all_aggr &= (exp_card(e) <= CARD_AGGR && !exp_is_atom(e) && is_aggr(e->type) && !is_func(e->type) && (!groupby || !is_groupby(groupby->op) || !groupby->r ||
MonetDB: default - Merged with Jun2020
Changeset: 3230faec824a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3230faec824a Added Files: sql/test/miscellaneous/Tests/create_func_temp.sql sql/test/miscellaneous/Tests/create_func_temp.stable.err sql/test/miscellaneous/Tests/create_func_temp.stable.out Modified Files: clients/examples/perl/sqlsample.pl clients/odbc/driver/ODBCConvert.c clients/odbc/driver/ODBCUtil.c clients/odbc/driver/SQLPrepare.c sql/server/rel_psm.c sql/server/rel_rel.c sql/server/rel_select.c sql/server/rel_unnest.c sql/server/rel_unnest.h sql/server/sql_scan.c sql/server/sql_scan.h sql/storage/store.c sql/test/BugTracker-2014/Tests/copy-into.Bug-3481.SQL.py sql/test/BugTracker-2014/Tests/utf8bom.Bug-3436.SQL.py sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.sql sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.stable.out sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.stable.out.int128 sql/test/BugTracker-2019/Tests/copy-into-from-stdin-empty-line.Bug-6669.sql sql/test/BugTracker-2019/Tests/insert-into-select.Bug-6718.sql sql/test/BugTracker-2019/Tests/python-loader-string.Bug-6759.py sql/test/Tests/unicode.sql sql/test/Tests/unicode.stable.out sql/test/Users/Tests/copyinto.SQL.py sql/test/Users/Tests/copyinto.stable.err sql/test/mapi/Tests/perl_dbi.stable.out sql/test/miscellaneous/Tests/All sql/test/subquery/Tests/subquery5.sql sql/test/subquery/Tests/subquery5.stable.err sql/test/subquery/Tests/subquery5.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 1712 to 300 lines): diff --git a/clients/examples/perl/sqlsample.pl b/clients/examples/perl/sqlsample.pl --- a/clients/examples/perl/sqlsample.pl +++ b/clients/examples/perl/sqlsample.pl @@ -48,6 +48,9 @@ my $dbh = DBI->connect( $dsn, $sth->bind_param( 1, 7 , DBI::SQL_INTEGER() ); $sth->bind_param( 2,'seven' ); $sth->execute; + $sth->bind_param( 1,42 , DBI::SQL_INTEGER() ); + $sth->bind_param( 2, '\\n' ); + $sth->execute; } { my $sth = $dbh->prepare('select * from perl_table;'); diff --git a/clients/odbc/driver/ODBCConvert.c b/clients/odbc/driver/ODBCConvert.c --- a/clients/odbc/driver/ODBCConvert.c +++ b/clients/odbc/driver/ODBCConvert.c @@ -3197,6 +3197,7 @@ ODBCStore(ODBCStmt *stmt, case SQL_WCHAR: case SQL_WVARCHAR: case SQL_WLONGVARCHAR: + assign(buf, bufpos, buflen, 'r', stmt); /* RAW string */ assign(buf, bufpos, buflen, '\'', stmt); switch (ctype) { case SQL_C_CHAR: @@ -3205,22 +3206,11 @@ ODBCStore(ODBCStmt *stmt, for (i = 0; i < slen; i++) { unsigned char c = (unsigned char) sval[i]; - if (c == 0) { + if (c == 0) break; - } else if (c < 0x20 /* || c >= 0x7F */) { - assign(buf, bufpos, buflen, '\\', stmt); - assign(buf, bufpos, buflen, '0' + (c >> 6), stmt); - assign(buf, bufpos, buflen, '0' + ((c >> 3) & 0x7), stmt); - assign(buf, bufpos, buflen, '0' + (c & 0x7), stmt); - } else if (c == '\\') { - assign(buf, bufpos, buflen, '\\', stmt); - assign(buf, bufpos, buflen, '\\', stmt); - } else if (c == '\'') { - assign(buf, bufpos, buflen, '\\', stmt); + if (c == '\'') assign(buf, bufpos, buflen, '\'', stmt); - } else { - assign(buf, bufpos, buflen, c, stmt); - } + assign(buf, bufpos, buflen, c, stmt); } break; case SQL_C_BIT: diff --git a/clients/odbc/driver/ODBCUtil.c b/clients/odbc/driver/ODBCUtil.c --- a/clients/odbc/driver/ODBCUtil.c +++ b/clients/odbc/driver/ODBCUtil.c @@ -679,7 +679,7 @@ ODBCTranslateSQL(ODBCDbc *dbc, const SQL length = (size_t) sprintf(q, "%.*s ESCAPE %s", n, nquery, p); break; case '\\': - length = (size_t) sprintf(q, "%.*s ESCAPE '' %s", n, nquery, p); + length = (size_t) sprintf(q, "%.*s ESCAPE r'\\' %s", n, nquery, p);
MonetDB: default - Merged with Jun2020
Changeset: 6e654e365e4c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6e654e365e4c Modified Files: gdk/gdk.h gdk/gdk_analytic.h geom/monetdb5/geom.c monetdb5/modules/kernel/status.c monetdb5/modules/mal/mal_io.c sql/backends/monet5/rel_bin.c sql/server/sql_mvc.c sql/server/sql_scan.c sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.sql sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.stable.err sql/test/BugTracker-2017/Tests/error-clean-cache.Bug-6351.sql sql/test/BugTracker-2017/Tests/error-clean-cache.Bug-6351.stable.err sql/test/BugTracker-2017/Tests/error-clean-cache.Bug-6351.stable.out sql/test/Tests/session_vars.sql sql/test/Tests/session_vars.stable.err sql/test/Tests/session_vars.stable.out sql/test/miscellaneous/Tests/declared_tables.sql sql/test/miscellaneous/Tests/declared_tables.stable.err sql/test/pg_regress/Tests/timestamp.sql sql/test/pg_regress/Tests/timestamptz.sql sql/test/ssqq/Tests/insert_query.stable.err sql/test/ssqq/Tests/insert_query.stable.out sql/test/ssqq/Tests/insert_queue.stable.err sql/test/ssqq/Tests/insert_queue.stable.out sql/test/ssqq/Tests/insert_quser.stable.err sql/test/ssqq/Tests/insert_quser.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 517 to 300 lines): diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -1928,10 +1928,6 @@ gdk_export int ALIGNsynced(BAT *b1, BAT gdk_export void BATassertProps(BAT *b); -#define BATPROPS_QUICK 0 /* only derive easy (non-resource consuming) properties */ -#define BATPROPS_ALL 1 /* derive all possible properties; no matter what cost (key=hash) */ -#define BATPROPS_CHECK 3 /* BATPROPS_ALL, but start from scratch and report illegally set properties */ - gdk_export BAT *VIEWcreate(oid seq, BAT *b); gdk_export void VIEWbounds(BAT *b, BAT *view, BUN l, BUN h); diff --git a/gdk/gdk_analytic.h b/gdk/gdk_analytic.h --- a/gdk/gdk_analytic.h +++ b/gdk/gdk_analytic.h @@ -14,8 +14,6 @@ #ifndef _GDK_ANALYTIC_H_ #define _GDK_ANALYTIC_H_ -#include "gdk.h" - gdk_export gdk_return GDKanalyticaldiff(BAT *r, BAT *b, BAT *p, int tpe); gdk_export gdk_return GDKanalyticalntile(BAT *r, BAT *b, BAT *p, BAT *n, int tpe, const void *restrict ntile); diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c --- a/geom/monetdb5/geom.c +++ b/geom/monetdb5/geom.c @@ -1594,11 +1594,15 @@ dumpGeometriesSingle(BAT *idBAT, BAT *ge snprintf(newPath, lvlDigitsNum + 1, "%u", *lvl); } else { //remove the comma at the end of the path - newPath = GDKmalloc(pathLength #ifdef STATIC_CODE_ANALYSIS - + 1 + /* coverity complains about the allocated space being +* too small, but we just want to reduce the length of +* the string by one, so the length in the #else part +* is exactly what we need */ + newPath = GDKmalloc(pathLength + 1); +#else + newPath = GDKmalloc(pathLength); #endif - ); if (newPath == NULL) { GDKfree(singleWKB); throw(MAL, "geom.Dump", SQLSTATE(HY013) MAL_MALLOC_FAIL); diff --git a/monetdb5/modules/kernel/status.c b/monetdb5/modules/kernel/status.c --- a/monetdb5/modules/kernel/status.c +++ b/monetdb5/modules/kernel/status.c @@ -633,7 +633,7 @@ SYSgdkThread(bat *ret, bat *ret2) thr = THRget(i); if (ATOMIC_GET(>pid)){ if (BUNappend(bn, >tid, false) != GDK_SUCCEED || - BUNappend(b, thr->name? thr->name:"", false) != GDK_SUCCEED) + BUNappend(b, thr->name, false) != GDK_SUCCEED) goto bailout; } } diff --git a/monetdb5/modules/mal/mal_io.c b/monetdb5/modules/mal/mal_io.c --- a/monetdb5/modules/mal/mal_io.c +++ b/monetdb5/modules/mal/mal_io.c @@ -550,7 +550,7 @@ IOtable(Client cntxt, MalBlkPtr mb, MalS ptr val; (void) cntxt; - if ( pci->retc != 1 || pci->argc < 2) + if ( pci->retc != 1 || pci->argc < 2 || pci->argc >= MAXPARAMS) throw(MAL, "io.table", "INTERNAL ERROR" " assertion error retc %d argc %d", pci->retc, pci->argc); memset(piv, 0, sizeof(BAT*) * MAXPARAMS); 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 @@ -789,12 +789,12 @@ exp_bin(backend *be, sql_exp *e, stmt *l as = exp_bin(be, at, left, right, NULL, NULL, NULL, sel); - if (as && as->nrcols <= 0 && left &&
MonetDB: default - Merged with Jun2020
Changeset: cfdd19ccca56 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cfdd19ccca56 Modified Files: common/utils/mstring.h gdk/gdk.h gdk/gdk_utils.c geom/lib/libgeom.c geom/monetdb5/geom.c sql/server/rel_select.c sql/storage/store.c sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.err sql/test/BugTracker-2009/Tests/assert_in_update.SF-2807336.stable.out sql/test/subquery/Tests/subquery5.sql sql/test/subquery/Tests/subquery5.stable.err testing/difflib.c Branch: default Log Message: Merged with Jun2020 diffs (truncated from 370 to 300 lines): diff --git a/common/utils/mstring.h b/common/utils/mstring.h --- a/common/utils/mstring.h +++ b/common/utils/mstring.h @@ -12,6 +12,12 @@ #include /* va_list etc. */ #include /* strlen */ +#ifdef __GNUC__ +#define GCC_Pragma(pragma) _Pragma(pragma) +#else +#define GCC_Pragma(pragma) +#endif + /* copy at most (n-1) bytes from src to dst and add a terminating NULL * byte; return length of src (i.e. can be more than what is copied) */ static inline size_t @@ -23,6 +29,20 @@ strcpy_len(char *restrict dst, const cha return i; } dst[n - 1] = 0; +/* This code is correct, but GCC gives a warning in certain + * conditions, so we disable the warning temporarily. + * The warning happens e.g. in + * strcpy_len(buf, "fixed string", sizeof(buf)) + * where buf is larger than the string. In that case we never get here + * since return is executed in the loop above, but the compiler + * complains anyway about reading out-of-bounds. + * For GCC we use _Pragma to disable the warning (and hence error). + * Since other compilers may warn (and hence error out) on + * unrecognized pragmas, we use some preprocessor trickery. */ +GCC_Pragma("GCC diagnostic push") +GCC_Pragma("GCC diagnostic ignored \"-Warray-bounds\"") + return n + strlen(src + n); +GCC_Pragma("GCC diagnostic pop") } return strlen(src); } diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -1709,10 +1709,10 @@ typedef struct threadStruct { * into this array + 1 (0 is * invalid) */ ATOMIC_TYPE pid;/* thread id, 0 = unallocated */ - str name; + char name[16]; void *data[THREADDATA]; uintptr_t sp; -} ThreadRec, *Thread; +} *Thread; gdk_export int THRgettid(void); diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c --- a/gdk/gdk_utils.c +++ b/gdk/gdk_utils.c @@ -931,7 +931,7 @@ GDKinit(opt *set, int setlen) int GDKnr_threads = 0; static ATOMIC_TYPE GDKnrofthreads = ATOMIC_VAR_INIT(0); -static ThreadRec GDKthreads[THREADS]; +static struct threadStruct GDKthreads[THREADS]; bool GDKexiting(void) @@ -983,8 +983,6 @@ GDKreset(int status) TRC_INFO(GDK, "Killing thread: %d\n", e); (void) ATOMIC_DEC(); } - GDKfree(t->name); - t->name = NULL; ATOMIC_SET(>pid, 0); } } @@ -1349,13 +1347,6 @@ GDK_find_self(void) static Thread THRnew(const char *name, MT_Id pid) { - char *nme = GDKstrdup(name); - - if (nme == NULL) { - TRC_DEBUG(IO_, "Malloc failure\n"); - GDKerror("malloc failure\n"); - return NULL; - } for (Thread s = GDKthreads; s < GDKthreads + THREADS; s++) { ATOMIC_BASE_TYPE npid = 0; if (ATOMIC_CAS(>pid, , pid)) { @@ -1363,7 +1354,7 @@ THRnew(const char *name, MT_Id pid) s->data[0] = THRdata[0]; s->data[1] = THRdata[1]; s->sp = THRsp(); - s->name = nme; + strcpy_len(s->name, name, sizeof(s->name)); TRC_DEBUG(PAR, "%x %zu sp = %zu\n", (unsigned) s->tid, (size_t) ATOMIC_GET(>pid), @@ -1373,7 +1364,6 @@ THRnew(const char *name, MT_Id pid) return s; } } - GDKfree(nme); TRC_DEBUG(IO_, "Too many threads\n"); GDKerror("too many threads\n"); return NULL; @@ -1428,8 +1418,6 @@ THRcreate(void (*f) (void *), void *arg, TRC_DEBUG(IO_, "Semaphore name is too large\n"); GDKerror("semaphore name is too large\n"); GDKfree(t); - GDKfree(s->name); - s->name = NULL; ATOMIC_SET(>pid, 0); /* deallocate */ return 0; } @@ -1438,8 +1426,6 @@ THRcreate(void (*f) (void *), void *arg, GDKerror("could not start
MonetDB: default - Merged with Jun2020
Changeset: 5e22614e48d7 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5e22614e48d7 Modified Files: clients/mapiclient/dotmonetdb.c clients/mapiclient/mclient.c common/utils/msabaoth.c gdk/gdk_aggr.c gdk/gdk_bbp.c gdk/gdk_logger.c gdk/gdk_string.c gdk/gdk_time.c gdk/gdk_tracer.c gdk/gdk_utils.c sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_gencode.c sql/backends/monet5/sql_statement.c sql/backends/monet5/sql_upgrades.c sql/server/rel_prop.c sql/server/rel_select.c sql/server/rel_unnest.c sql/server/rel_unnest.h sql/test/subquery/Tests/subquery4.sql sql/test/subquery/Tests/subquery4.stable.err sql/test/subquery/Tests/subquery4.stable.out sql/test/subquery/Tests/subquery5.sql sql/test/subquery/Tests/subquery5.stable.err sql/test/subquery/Tests/subquery5.stable.out tools/merovingian/daemon/controlrunner.c tools/merovingian/daemon/forkmserver.c tools/merovingian/daemon/merovingian.c Branch: default Log Message: Merged with Jun2020 diffs (truncated from 1245 to 300 lines): diff --git a/clients/mapiclient/dotmonetdb.c b/clients/mapiclient/dotmonetdb.c --- a/clients/mapiclient/dotmonetdb.c +++ b/clients/mapiclient/dotmonetdb.c @@ -17,6 +17,8 @@ parse_dotmonetdb(DotMonetdb *dotfile) FILE *config = NULL; char buf[FILENAME_MAX]; + if (dotfile == NULL) + return; if ((cfile = getenv("DOTMONETDBFILE")) == NULL) { /* no environment variable: use a default */ if ((config = fopen(".monetdb", "r")) == NULL) { @@ -46,9 +48,7 @@ parse_dotmonetdb(DotMonetdb *dotfile) cfile = strdup(cfile); } -if (dotfile) { - *dotfile = (DotMonetdb) {0}; -} + *dotfile = (DotMonetdb) {0}; if (config) { int line = 0; diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -3252,7 +3252,6 @@ main(int argc, char **argv) } /* parse config file first, command line options override */ - // parse_dotmonetdb(, , , , _history, , ); parse_dotmonetdb(); user = dotfile.user; passwd = dotfile.passwd; diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c --- a/common/utils/msabaoth.c +++ b/common/utils/msabaoth.c @@ -750,6 +750,11 @@ msab_getStatus(sabdb** ret, char *dbname sabdb *sdb; sdb = *ret = NULL; + if (dbname && strpbrk(dbname, "/\\") != NULL) { + snprintf(data, sizeof(data), +"database name contains disallowed characters"); + return strdup(data); + } /* scan the parent for directories */ if ((p = getFarmPath(pathbuf, sizeof(pathbuf), NULL)) != NULL) return(p); diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c --- a/gdk/gdk_aggr.c +++ b/gdk/gdk_aggr.c @@ -3759,7 +3759,7 @@ BATgroupcorrelation(BAT *b1, BAT *b2, BA (BATcount(e) == BATcount(b1) && (e->hseqbase == b1->hseqbase || e->hseqbase == b2->hseqbase))) && (BATtdense(g) || (g->tkey && g->tnonil))) { dbl v = dbl_nil; - return BATconstant(ngrp == 0 ? 0 : min, TYPE_dbl, , ngrp, TRANSIENT); + return BATconstant(min, TYPE_dbl, , ngrp, TRANSIENT); } delta1 = GDKmalloc(ngrp * sizeof(dbl)); diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -491,8 +491,9 @@ fixdateheap(BAT *b, const char *anme) TRC_CRITICAL(GDK, "GDKfilepath failed\n"); return GDK_FAIL; } - /* coverity[null_returns] */ - *strrchr(srcdir, DIR_SEP) = 0; + char *s; + if ((s = strrchr(srcdir, DIR_SEP)) != NULL) + *s = 0; if ((bnme = strrchr(nme, DIR_SEP)) != NULL) bnme++; @@ -943,6 +944,7 @@ BBPreadEntries(FILE *fp, unsigned bbpver if ((s = strchr(headname, '~')) != NULL && s == headname) { int len = snprintf(logical, sizeof(logical), "tmp_%o", (unsigned) bid); if (len == -1 || len >= (int) sizeof(logical)) { + BATdestroy(bn); TRC_CRITICAL(GDK, "BBP logical filename directory is too large\n"); return GDK_FAIL; } diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -3062,8 +3062,7 @@ log_sequence_(logger *lg, int seq, lng v if (log_write_format(lg, ) != GDK_SUCCEED || !mnstr_writeLng(lg->log, val) || (flush && mnstr_flush(lg->log)) || - (flush && !(GDKdebug & NOSYNCMASK) &&
MonetDB: default - Merged with Jun2020
Changeset: af154c17f842 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=af154c17f842 Modified Files: sql/storage/store.c sql/test/subquery/Tests/subquery5.sql Branch: default Log Message: Merged with Jun2020 diffs (37 lines): diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -1869,14 +1869,12 @@ store_load(backend_stack stk) { types_init(store_sa); - // TODO: Niels: Are we fine running this twice? - /* we store some spare oids */ store_oid = FUNC_OIDS; if (!sequences_init()) return -1; - transactions = ATOMIC_VAR_INIT(0); + ATOMIC_SET(, 0); gtrans = tr = create_trans(sa, stk); if (!gtrans) return -1; diff --git a/sql/test/subquery/Tests/subquery5.sql b/sql/test/subquery/Tests/subquery5.sql --- a/sql/test/subquery/Tests/subquery5.sql +++ b/sql/test/subquery/Tests/subquery5.sql @@ -86,6 +86,14 @@ SELECT corr(i1.i, i2.i) OVER () FROM int SELECT (SELECT SUM(i1.i) IN (SELECT CORR(i1.i, i2.i) FROM integers i2)) FROM integers i1; --error, subquery uses ungrouped column "i1.i" from outer query +SELECT (SELECT corr(col1, SUM(col2))) FROM another_t; --error, aggregate function calls cannot be nested + +SELECT (SELECT corr(col1, col2) WHERE corr(col3, SUM(col4)) > 0) FROM another_t GROUP BY col5; --error, aggregate function calls cannot be nested + +SELECT (SELECT 1 GROUP BY SUM(col2 + 1)) FROM another_t; --should we allow this? + +SELECT (SELECT 1 WHERE SUM(col2 + 1) > 0) FROM another_t; --allow this? + DROP FUNCTION evilfunction(INT); DROP TABLE tbl_ProductSales; DROP TABLE another_T; ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Merged with Jun2020
Changeset: ff9dc7b6f851 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ff9dc7b6f851 Modified Files: clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 clients/Tests/exports.stable.out monetdb5/modules/kernel/bat5.c monetdb5/optimizer/opt_prelude.c monetdb5/optimizer/opt_prelude.h monetdb5/optimizer/opt_support.c sql/backends/monet5/sql.c sql/backends/monet5/sql.h sql/backends/monet5/sql.mal sql/backends/monet5/sql_statement.c sql/test/miscellaneous/Tests/declared_tables.sql sql/test/miscellaneous/Tests/declared_tables.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 392 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 @@ -14077,7 +14077,7 @@ stdout of test 'MAL-signatures` in direc [ "sql", "dec_round","command sql.dec_round(v:int, r:int):int ", "int_dec_round_wrap;", "round off the value v to nearests multiple of r" ] [ "sql", "dec_round","command sql.dec_round(v:lng, r:lng):lng ", "lng_dec_round_wrap;", "round off the value v to nearests multiple of r" ] [ "sql", "dec_round","command sql.dec_round(v:sht, r:sht):sht ", "sht_dec_round_wrap;", "round off the value v to nearests multiple of r" ] -[ "sql", "delete", "unsafe pattern sql.delete(mvc:int, sname:str, tname:str, b:any):int ", "mvc_delete_wrap;", "Delete a row from a table. Returns sequence number for order dependece." ] +[ "sql", "delete", "unsafe pattern sql.delete(mvc:int, sname:str, tname:str, b:any):int ", "mvc_delete_wrap;", "Delete a row from a table. Returns sequence number for order dependence." ] [ "sql", "delta","command sql.delta(col:bat[:any_3], uid:bat[:oid], uval:bat[:any_3]):bat[:any_3] ", "DELTAbat2;", "Return column bat with delta's applied." ] [ "sql", "delta","command sql.delta(col:bat[:any_3], uid:bat[:oid], uval:bat[:any_3], ins:bat[:any_3]):bat[:any_3] ", "DELTAbat;","Return column bat with delta's applied." ] [ "sql", "deltas", "pattern sql.deltas(schema:str) (ids:bat[:int], cleared:bat[:bit], readonly:bat[:lng], inserted:bat[:lng], updated:bat[:lng], deleted:bat[:lng], tr_level:bat[:int]) ", "mvc_delta_values;","Return the delta values sizes of all columns of the schema's tables, plus the current transaction level" ] 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 @@ -19534,7 +19534,7 @@ stdout of test 'MAL-signatures` in direc [ "sql", "dec_round","command sql.dec_round(v:int, r:int):int ", "int_dec_round_wrap;", "round off the value v to nearests multiple of r" ] [ "sql", "dec_round","command sql.dec_round(v:lng, r:lng):lng ", "lng_dec_round_wrap;", "round off the value v to nearests multiple of r" ] [ "sql", "dec_round","command sql.dec_round(v:sht, r:sht):sht ", "sht_dec_round_wrap;", "round off the value v to nearests multiple of r" ] -[ "sql", "delete", "unsafe pattern sql.delete(mvc:int, sname:str, tname:str, b:any):int ", "mvc_delete_wrap;", "Delete a row from a table. Returns sequence number for order dependece." ] +[ "sql", "delete", "unsafe pattern sql.delete(mvc:int, sname:str, tname:str, b:any):int ", "mvc_delete_wrap;", "Delete a row from a table. Returns sequence number for order dependence." ] [ "sql", "delta","command sql.delta(col:bat[:any_3], uid:bat[:oid], uval:bat[:any_3]):bat[:any_3] ", "DELTAbat2;", "Return column bat with delta's applied." ] [ "sql", "delta","command sql.delta(col:bat[:any_3], uid:bat[:oid], uval:bat[:any_3], ins:bat[:any_3]):bat[:any_3] ", "DELTAbat;","Return column bat with delta's applied." ] [ "sql", "deltas", "pattern sql.deltas(schema:str) (ids:bat[:int], cleared:bat[:bit], readonly:bat[:lng], inserted:bat[:lng], updated:bat[:lng], deleted:bat[:lng], tr_level:bat[:int]) ", "mvc_delta_values;","Return the delta values sizes of all columns of the schema's tables, plus the current transaction level" ] diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -2043,6 +2043,7 @@ int bstream_destroy_wrap(Bstream *BS); str bstream_destroy_wrapwrap(void *ret, Bstream *BS); int bstream_read_wrap(int *res, Bstream *BS, int *size); str bstream_read_wrapwrap(int *res,
MonetDB: default - Merged with Jun2020
Changeset: a6dfdf4a42ed for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a6dfdf4a42ed Modified Files: clients/mapilib/mapi.c gdk/gdk_aggr.c gdk/gdk_analytic_func.c gdk/gdk_select.c sql/backends/monet5/UDF/pyapi3/connection3.c sql/backends/monet5/UDF/pyapi3/emit3.c sql/server/rel_optimizer.c sql/server/rel_psm.c sql/server/rel_select.c sql/server/rel_updates.c sql/storage/store.c sql/test/mergetables/Tests/sqlsmith-exists2.sql sql/test/mergetables/Tests/sqlsmith-exists2.stable.out sql/test/miscellaneous/Tests/groupby_error.sql sql/test/miscellaneous/Tests/groupby_error.stable.out sql/test/subquery/Tests/subquery5.sql sql/test/subquery/Tests/subquery5.stable.err sql/test/subquery/Tests/subquery5.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 1445 to 300 lines): diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1000,13 +1000,13 @@ static void mapi_store_bind(struct MapiR static ATOMIC_FLAG mapi_initialized = ATOMIC_FLAG_INIT; -#define check_stream(mid,s,msg,f,e)\ +#define check_stream(mid, s, msg, e) \ do {\ if ((s) == NULL || mnstr_errnr(s)) {\ - mapi_log_record(mid,msg); \ - mapi_log_record(mid,f); \ + mapi_log_record(mid, msg); \ + mapi_log_record(mid, __func__); \ close_connection(mid); \ - mapi_setError((mid), (msg), (f), MTIMEOUT); \ + mapi_setError((mid), (msg), __func__, MTIMEOUT); \ return (e); \ } \ } while (0) @@ -1420,7 +1420,7 @@ mapi_log(Mapi mid, const char *nme) if (mid->tracelog) close_stream(mid->tracelog); mid->tracelog = NULL; - return mapi_setError(mid, "Could not create log file", "mapi_log", MERROR); + return mapi_setError(mid, "Could not create log file", __func__, MERROR); } return MOK; } @@ -1529,7 +1529,7 @@ close_result(MapiHdl hdl) if (mnstr_printf(mid->to, "%s", msg) < 0 || mnstr_flush(mid->to)) { close_connection(mid); - mapi_setError(mid, mnstr_error(mid->to), "mapi_close_handle", MTIMEOUT); + mapi_setError(mid, mnstr_error(mid->to), __func__, MTIMEOUT); break; } read_into_cache(hdl, 0); @@ -1547,7 +1547,7 @@ close_result(MapiHdl hdl) if (mnstr_printf(mid->to, "%s", msg) < 0 || mnstr_flush(mid->to)) { close_connection(mid); - mapi_setError(mid, mnstr_error(mid->to), "mapi_close_handle", MTIMEOUT); + mapi_setError(mid, mnstr_error(mid->to), __func__, MTIMEOUT); } else read_into_cache(hdl, 0); } @@ -1725,7 +1725,7 @@ mapi_new_handle(Mapi mid) hdl = malloc(sizeof(*hdl)); if (hdl == NULL) { - mapi_setError(mid, "Memory allocation failure", "mapi_new_handle", MERROR); + mapi_setError(mid, "Memory allocation failure", __func__, MERROR); return NULL; } *hdl = (struct MapiStatement) { @@ -1759,7 +1759,7 @@ finish_handle(MapiHdl hdl) hdl->needmore = false; mid->active = hdl; mnstr_flush(mid->to); - check_stream(mid, mid->to, "write error on stream", "finish_handle", mid->error); + check_stream(mid, mid->to, "write error on stream", mid->error); read_into_cache(hdl, 0); } for (i = 0; i < hdl->npending_close; i++) { @@ -1771,7 +1771,7 @@ finish_handle(MapiHdl hdl) if (mnstr_printf(mid->to, "%s", msg) < 0 || mnstr_flush(mid->to)) { close_connection(mid); - mapi_setError(mid, mnstr_error(mid->to), "finish_handle",
MonetDB: default - Merged with Jun2020
Changeset: 33be2b324bb6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=33be2b324bb6 Added Files: sql/test/BugTracker-2020/Tests/global_table_propagation.Bug-6846.py sql/test/BugTracker-2020/Tests/global_table_propagation.Bug-6846.stable.err sql/test/BugTracker-2020/Tests/global_table_propagation.Bug-6846.stable.out Modified Files: clients/Tests/All clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 clients/Tests/SingleServer monetdb5/modules/mal/tablet.c monetdb5/optimizer/opt_pushselect.c sql/ChangeLog.Jun2020 sql/backends/monet5/sql.c sql/backends/monet5/sql_cat.c sql/backends/monet5/sql_result.c sql/server/rel_schema.c sql/server/sql_mvc.c sql/server/sql_partition.c sql/storage/bat/bat_storage.c sql/storage/sql_storage.h sql/storage/store.c sql/test/BugTracker-2018/Tests/nested-merge-tables.Bug-6585.stable.err sql/test/BugTracker-2019/Tests/grant-select-column.Bug-6765.py sql/test/BugTracker-2019/Tests/grant-select-column.Bug-6765.stable.err sql/test/BugTracker-2019/Tests/grant-select-column.Bug-6765.stable.out sql/test/BugTracker-2019/Tests/python-loader-string.Bug-6759.py sql/test/BugTracker-2019/Tests/python-loader-string.Bug-6759.stable.err sql/test/BugTracker-2019/Tests/python-loader-string.Bug-6759.stable.out sql/test/BugTracker-2020/Tests/All sql/test/BugTracker-2020/Tests/alter-table-add-column.Bug-6816.py sql/test/BugTracker-2020/Tests/alter-table-add-column.Bug-6816.stable.err sql/test/BugTracker-2020/Tests/alter-table-add-column.Bug-6816.stable.out sql/test/BugTracker-2020/Tests/functions-not-persist.Bug-6819.SQL.py sql/test/BugTracker-2020/Tests/functions-not-persist.Bug-6819.stable.err sql/test/BugTracker-2020/Tests/functions-not-persist.Bug-6819.stable.out sql/test/merge-partitions/Tests/mergepart05.stable.err sql/test/merge-partitions/Tests/mergepart07.stable.err sql/test/mergetables/Tests/mergedropcrash.stable.err sql/test/pg_regress/Tests/alter_table.stable.err sql/test/pg_regress/Tests/drop.stable.err Branch: default Log Message: Merged with Jun2020 diffs (truncated from 1895 to 300 lines): diff --git a/clients/Tests/All b/clients/Tests/All --- a/clients/Tests/All +++ b/clients/Tests/All @@ -1,4 +1,4 @@ exports -HAVE_FITS_GEOM_LIBR_LIDAR_NETCDF_SHP?MAL-signatures +HAVE_FITS_GEOM_LIBR_LIBPY3_LIDAR_NETCDF_SHP_WIN32?MAL-signatures MERCURIAL?malcheck mclient-uri 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 @@ -64,7 +64,7 @@ stdout of test 'MAL-signatures` in direc % .%1, .%1,.%1,.%1,.%1 # table_name % module, function, signature, address,comment # name % clob,clob, clob, clob, clob # type -% 10, 28, 364,38, 874 # length +% 12, 28, 364,38, 874 # length [ "aggr", "allnotequal", "command aggr.allnotequal(l:bat[:any_1], r:bat[:any_1]):bit ", "SQLallnotequal;", "if all values in r are not equal to l return true, else if r has nil nil else false" ] [ "aggr", "anyequal", "pattern aggr.anyequal(l:any_1, r:any_1):bit ", "CMDvarEQ;","" ] [ "aggr", "anyequal", "command aggr.anyequal(l:bat[:any_1], r:bat[:any_1]):bit ", "SQLanyequal;", "if any value in r is equal to l return true, else if r has nil nil else false" ] @@ -11242,6 +11242,14 @@ stdout of test 'MAL-signatures` in direc [ "batmtime", "year", "command batmtime.year(d:bat[:date]):bat[:int] ", "MTIMEdate_extract_year_bulk;", "" ] [ "batpcre", "replace", "command batpcre.replace(orig:bat[:str], pat:str, repl:str, flag:str):bat[:str] ", "PCREreplace_bat_wrap;", "" ] [ "batpcre", "replace_first","command batpcre.replace_first(orig:bat[:str], pat:str, repl:str, flag:str):bat[:str] ", "PCREreplacefirst_bat_wrap;", "" ] +[ "batpyapi3", "eval", "unsafe pattern batpyapi3.eval(fptr:ptr, expr:str, arg:any...):any... ","PYAPI3PyAPIevalStd;", "Execute a simple Python script value" ] +[ "batpyapi3", "eval_aggr","unsafe pattern batpyapi3.eval_aggr(fptr:ptr, expr:str, arg:any...):any... ", "PYAPI3PyAPIevalAggr;", "grouped aggregates through Python" ] +[ "batpyapi3", "eval_loader", "unsafe pattern batpyapi3.eval_loader(fptr:ptr, expr:str):any... ", "PYAPI3PyAPIevalLoader;", "loader functions through Python" ] +[ "batpyapi3", "eval_loader", "unsafe pattern batpyapi3.eval_loader(fptr:ptr, expr:str, arg:any...):any... ", "PYAPI3PyAPIevalLoader;", "loader functions through Python" ] +[ "batpyapi3",
MonetDB: default - Merged with Jun2020
Changeset: 4a65076da211 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4a65076da211 Modified Files: monetdb5/mal/mal_linker.c monetdb5/mal/mal_resolve.c sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_cat.c sql/backends/monet5/sql_execute.c sql/common/sql_list.c sql/include/sql_catalog.h sql/include/sql_list.h sql/server/rel_propagate.c sql/server/rel_select.c sql/server/rel_semantic.c sql/server/rel_unnest.c sql/server/rel_updates.c sql/server/sql_partition.c sql/storage/sql_catalog.c sql/storage/store.c sql/test/merge-partitions/Tests/mergepart23.SQL.py sql/test/merge-partitions/Tests/mergepart23.stable.err sql/test/subquery/Tests/subquery5.sql sql/test/subquery/Tests/subquery5.stable.err Branch: default Log Message: Merged with Jun2020 diffs (truncated from 595 to 300 lines): diff --git a/monetdb5/mal/mal_linker.c b/monetdb5/mal/mal_linker.c --- a/monetdb5/mal/mal_linker.c +++ b/monetdb5/mal/mal_linker.c @@ -439,22 +439,40 @@ MSP_locate_sqlscript(const char *filenam return locate_file(filename, SQL_EXT, recurse); } - int -malLibraryEnabled(str name) { +malLibraryEnabled(str name) +{ if (strcmp(name, "pyapi3") == 0) { const char *val = GDKgetenv("embedded_py"); return val && (strcmp(val, "3") == 0 || strcasecmp(val, "true") == 0 || strcasecmp(val, "yes") == 0); + } else if (strcmp(name, "rapi") == 0) { + const char *val = GDKgetenv("embedded_r"); + return val && (strcasecmp(val, "true") == 0 || + strcasecmp(val, "yes") == 0); + } else if (strcmp(name, "capi") == 0) { + const char *val = GDKgetenv("embedded_c"); + return val && (strcasecmp(val, "true") == 0 || + strcasecmp(val, "yes") == 0); } return true; } -char* -malLibraryHowToEnable(str name) { +#define HOW_TO_ENABLE_ERROR(LANGUAGE, OPTION) \ + if (malLibraryEnabled(name)) \ + return "Embedded " LANGUAGE " has not been installed. Please install it first, then start server with --set " OPTION; \ + return "Embedded " LANGUAGE " has not been enabled. Start server with --set " OPTION; + +char * +malLibraryHowToEnable(str name) +{ if (strcmp(name, "pyapi3") == 0) { - return "Embedded Python 3 has not been enabled. Start server with --set embedded_py=3"; + HOW_TO_ENABLE_ERROR("Python 3", "embedded_py=3") + } else if (strcmp(name, "rapi") == 0) { + HOW_TO_ENABLE_ERROR("R", "embedded_r=true") + } else if (strcmp(name, "capi") == 0) { + HOW_TO_ENABLE_ERROR("C/C++", "embedded_c=true") } return ""; } diff --git a/monetdb5/mal/mal_resolve.c b/monetdb5/mal/mal_resolve.c --- a/monetdb5/mal/mal_resolve.c +++ b/monetdb5/mal/mal_resolve.c @@ -536,7 +536,7 @@ typeChecker(Module scope, MalBlkPtr mb, */ if (!isaSignature(p) && !getInstrPtr(mb, 0)->polymorphic) { if (!silent) { - char *errsig; + char *errsig = NULL; if (!malLibraryEnabled(p->modname)) { mb->errors = createMalException(mb, idx, TYPE, "'%s%s%s' library error in: %s", @@ -544,13 +544,21 @@ typeChecker(Module scope, MalBlkPtr mb, (getModuleId(p) ? "." : ""), getFunctionId(p), malLibraryHowToEnable(p->modname)); } else { - errsig = instruction2str(mb,0,p, (LIST_MAL_NAME | LIST_MAL_TYPE | LIST_MAL_VALUE)); + bool free_errsig = false, special_undefined = false; + errsig = malLibraryHowToEnable(p->modname); + if (!strcmp(errsig, "")) { + errsig = instruction2str(mb,0,p, (LIST_MAL_NAME | LIST_MAL_TYPE | LIST_MAL_VALUE)); + free_errsig = true; + } else { + special_undefined = true; + } mb->errors = createMalException(mb, idx, TYPE, - "'%s%s%s' undefined in: %s", +
MonetDB: default - Merged with Jun2020
Changeset: 68f53eb16440 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=68f53eb16440 Added Files: sql/test/miscellaneous/Tests/table_udf_missing_var.py sql/test/miscellaneous/Tests/table_udf_missing_var.stable.err sql/test/miscellaneous/Tests/table_udf_missing_var.stable.out Modified Files: clients/mapiclient/stethoscope.c clients/mapilib/mapi.c configure.ag gdk/Makefile.ag gdk/gdk_calc.c gdk/gdk_join.c gdk/gdk_utils.c sql/backends/monet5/UDF/capi/capi.c sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_statement.c sql/server/rel_optimizer.c sql/test/miscellaneous/Tests/All tools/merovingian/daemon/forkmserver.c Branch: default Log Message: Merged with Jun2020 diffs (truncated from 2970 to 300 lines): diff --git a/clients/mapiclient/stethoscope.c b/clients/mapiclient/stethoscope.c --- a/clients/mapiclient/stethoscope.c +++ b/clients/mapiclient/stethoscope.c @@ -79,7 +79,7 @@ static FILE *trace ; * Tuple level reformatting */ -static void +static _Noreturn void usageStethoscope(void) { fprintf(stderr, "stethoscope [options] \n"); @@ -210,20 +210,14 @@ main(int argc, char **argv) break; case '?': usageStethoscope(); - /* a bit of a hack: look at the option that the - current `c' is based on and see if we recognize - it: if -? or --help, exit with 0, else with -1 */ - exit(strcmp(argv[optind - 1], "-?") == 0 || strcmp(argv[optind - 1], "--help") == 0 ? 0 : -1); default: usageStethoscope(); - exit(-1); } } if(dbname == NULL){ usageStethoscope(); - exit(-1); } if(debug) diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -1248,6 +1248,8 @@ void mapi_noexplain(Mapi mid, const char *errorprefix) { assert(mid); + if (mid->noexplain) + free(mid->noexplain); mid->noexplain = errorprefix ? strdup(errorprefix) : NULL; } diff --git a/configure.ag b/configure.ag --- a/configure.ag +++ b/configure.ag @@ -810,7 +810,7 @@ AC_MSG_CHECKING([for --enable-optimize]) AS_CASE([$enable_optimize], [yes], [ # if optimizing *and* enable-strict, use FORTIFY_SOURCE AS_VAR_IF([enable_strict], [yes], [ - CFLAGS="-D_FORTIFY_SOURCE=2 $CFLAGS"]) + MCHECK_ADD_FLAG([-D_FORTIFY_SOURCE=2])]) origCFLAGS="$CFLAGS" # remove "-O2" as we add "-Ox" and some compilers don't like "-Oy -Ox" combinations CFLAGS=`AS_ECHO([" $CFLAGS "]) | sed -e 's| -O2 | |g' -e 's|^ ||' -e 's| $||'` diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag --- a/gdk/Makefile.ag +++ b/gdk/Makefile.ag @@ -12,34 +12,45 @@ lib_gdk = { VERSION = $(GDK_VERSION) NAME = bat SOURCES = \ + gdk_calc.c gdk_calc.h gdk_calc_compare.h gdk_calc_private.h \ gdk_select.c \ - gdk_calc.c gdk_calc.h gdk_calc_compare.h gdk_calc_private.h \ + gdk_analytic_bounds.c gdk_analytic.h \ + gdk_qsort.c gdk_qsort_impl.h \ gdk_ssort.c gdk_ssort_impl.h \ gdk_aggr.c \ - gdk.h gdk_batop.c \ - gdk_cand.h gdk_cand.c \ - gdk_search.c gdk_hash.c gdk_hash.h gdk_tm.c \ + gdk_analytic_func.c \ + gdk_bbp.c gdk_bbp.h \ + gdk_group.c \ + gdk_join.c \ + gdk_firstn.c \ + gdk_logger.c gdk_logger.h gdk_geomlogger.h gdk_logger_internals.h \ + gdk_batop.c \ + gdk_bat.c \ + gdk_hash.c gdk_hash.h \ + gdk_utils.c gdk_utils.h \ + gdk_imprints.c gdk_imprints.h \ + gdk_atoms.c gdk_atoms.h \ + gdk_project.c \ + gdk_string.c \ gdk_orderidx.c \ - gdk_align.c gdk_bbp.c gdk_bbp.h \ - gdk_heap.c gdk_utils.c gdk_utils.h \ - gdk_atoms.c gdk_atoms.h gdk_string.c \ - gdk_qsort.c gdk_qsort_impl.h \ - gdk_storage.c gdk_bat.c \ - gdk_delta.c gdk_cross.c gdk_system.c gdk_value.c \ - gdk_posix.c gdk_logger.c gdk_sample.c xoshiro256starstar.h \ - gdk_private.h gdk_delta.h gdk_logger.h gdk_posix.h \ - gdk_system.h gdk_system_private.h gdk_tm.h gdk_storage.h \ - gdk_geomlogger.h gdk_logger_internals.h \ - gdk_group.c \ - gdk_imprints.c gdk_imprints.h \ - gdk_join.c gdk_project.c \ + gdk_search.c \ + gdk_heap.c \ +
MonetDB: default - Merged with Jun2020
Changeset: 60ab566c3ee0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=60ab566c3ee0 Removed Files: debian/fix-deb.sh Modified Files: clients/mapilib/monetdb-mapi.pc.in debian/monetdb5-sql.install gdk/gdk_aggr.c sql/backends/monet5/sql_cat.c sql/server/rel_psm.c sql/server/rel_schema.c sql/server/rel_select.c sql/server/rel_updates.c sql/server/sql_mvc.c sql/test/miscellaneous/Tests/declared_tables.sql sql/test/miscellaneous/Tests/declared_tables.stable.err sql/test/miscellaneous/Tests/declared_tables.stable.out sql/test/miscellaneous/Tests/groupby_error.sql sql/test/miscellaneous/Tests/simple_selects.sql sql/test/miscellaneous/Tests/simple_selects.stable.err sql/test/miscellaneous/Tests/simple_selects.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 1020 to 300 lines): diff --git a/clients/mapilib/monetdb-mapi.pc.in b/clients/mapilib/monetdb-mapi.pc.in --- a/clients/mapilib/monetdb-mapi.pc.in +++ b/clients/mapilib/monetdb-mapi.pc.in @@ -4,15 +4,15 @@ # # Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${exec_prefix} -libdir=${libdir} -includedir=${includedir} +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ Name: monetdb-mapi Description: MonetDB MAPI C-client libary -Version: @MONETDB_VERSION@ +Version: @PACKAGE_VERSION@ Requires: monetdb-stream openssl -Libs: -L${libdir} -lmapi +Libs: -L${libdir} -lmapi @SOCKET_LIBS@ Cflags: -I${includedir}/monetdb diff --git a/debian/fix-deb.sh b/debian/fix-deb.sh deleted file mode 100755 --- a/debian/fix-deb.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -case $# in -0) -# figure out which distribution this is -if [ -f /etc/lsb-release ]; then - source /etc/lsb-release - SUITE=$DISTRIB_CODENAME -elif [ -f /etc/os-release ]; then - source /etc/os-release - if [[ $ID == debian ]]; then - SUITE="${VERSION#*(}" - SUITE="${SUITE%)*}" - else - case $VERSION in - *\(*\)*) - SUITE="${VERSION#*(}" - SUITE="${SUITE% *)*}" - ;; - *) - SUITE="${VERSION#*, }" - SUITE="${SUITE% *)*}" - ;; - esac - SUITE=${SUITE,,} - fi -else - echo "don't know what distro this is" - exit 1 -fi -ARCH=$(arch) -;; -1) -# we're passed the name of the distribution -SUITE=$1 -ARCH=$(arch) -;; -2) -SUITE=$1 -ARCH=$2 -;; -esac - -if [[ $ARCH == i?86 ]]; then -ARCH=i386 # normalize -fi - -case $SUITE in -jessie) -# Debian 8 still have php5-cli and doesn't have php*-sockets; -# newer ones use php-cli and do have php-sockets. -sed -i 's/php-cli/php5-cli/;s/, *php-sockets//' debian/control - -# The Python 3 version is too old for py3integration. -sed -i '/^Package: monetdb-python3/,/^$/d' debian/control -sed -i 's/ python3-dev, python3-numpy,//' debian/control -rm debian/monetdb-python3.install -sed -i 's/py3integration=yes/py3integration=no/' debian/rules -;; -eoan) -# Ubuntu 19.10 (Eoan Ermine) doesn't have liblas-c-dev, hence no LiDAR -sed -i 's/ liblas-c-dev[^,]*,//' debian/control -sed -i '/^Package: libmonetdb5-server-lidar/,/^$/d' debian/control -sed -i '/--enable-lidar=yes/s/yes/no/;/--enable-liblas=yes/s/yes/no/' debian/rules -;; -esac - -# debhelper compatibility 9 and later support multiarch by using -# architecture-specific subdirectories in /usr/lib (and /lib); our -# code base is set up for amd64 (x86_64), so change to whatever -# architecture we're compiling for -case $ARCH in -x86_64 | amd64) -;; -*) -sed -i "s/x86_64/$ARCH/g" debian/*.install -;; -esac diff --git a/debian/monetdb5-sql.install b/debian/monetdb5-sql.install --- a/debian/monetdb5-sql.install +++ b/debian/monetdb5-sql.install @@ -7,7 +7,6 @@ debian/tmp/etc/tmpfiles.d/monetdbd.conf # usr/lib/x86_64-linux-gnu/monetdb5/sql*.mal EXCEPT: sql*_hge.mal debian/tmp/usr/lib/x86_64-linux-gnu/monetdb5/sql.mal usr/lib/x86_64-linux-gnu/monetdb5 debian/tmp/usr/lib/x86_64-linux-gnu/monetdb5/sql[!_]*.mal usr/lib/x86_64-linux-gnu/monetdb5 -debian/tmp/usr/lib/x86_64-linux-gnu/monetdb5/sql_aggr_[!h]*.mal usr/lib/x86_64-linux-gnu/monetdb5 debian/tmp/usr/lib/x86_64-linux-gnu/monetdb5/sql_decimal.mal usr/lib/x86_64-linux-gnu/monetdb5 debian/tmp/usr/lib/x86_64-linux-gnu/monetdb5/sql_rank.mal usr/lib/x86_64-linux-gnu/monetdb5 debian/tmp/usr/lib/x86_64-linux-gnu/monetdb5/sql_[!adhr]*.mal usr/lib/x86_64-linux-gnu/monetdb5 diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c --- a/gdk/gdk_aggr.c +++ b/gdk/gdk_aggr.c @@ -896,11 +896,11 @@ BATgroupsum(BAT *b, BAT *g, BAT *e, BAT lng t0 = GDKusec();
MonetDB: default - Merged with Jun2020
Changeset: faa99f033099 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=faa99f033099 Modified Files: gdk/ChangeLog.Jun2020 gdk/gdk.h gdk/gdk_atoms.c gdk/gdk_atoms.h gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_bbp.c gdk/gdk_delta.c gdk/gdk_project.c monetdb5/mal/mal_atom.c monetdb5/mal/mal_interpreter.c monetdb5/mal/mal_stack.c sql/backends/monet5/rel_bin.c sql/server/rel_optimizer.c sql/server/rel_select.c sql/test/BugTracker-2008/Tests/is_distinct_broken.SF-2430201.sql sql/test/BugTracker-2008/Tests/is_distinct_broken.SF-2430201.stable.err sql/test/BugTracker-2008/Tests/is_distinct_broken.SF-2430201.stable.out sql/test/miscellaneous/Tests/groupby_error.sql sql/test/miscellaneous/Tests/groupby_error.stable.out sql/test/subquery/Tests/subquery4.sql sql/test/subquery/Tests/subquery4.stable.err sql/test/subquery/Tests/subquery4.stable.out Branch: default Log Message: Merged with Jun2020 diffs (truncated from 777 to 300 lines): diff --git a/gdk/ChangeLog.Jun2020 b/gdk/ChangeLog.Jun2020 --- a/gdk/ChangeLog.Jun2020 +++ b/gdk/ChangeLog.Jun2020 @@ -1,6 +1,10 @@ # ChangeLog file for GDK # This file is updated with Maddlog +* Fri Mar 20 2020 Sjoerd Mullender +- Changed the interface of the atom "fix" and "unfix" functions. + They now return a value of type gdk_return to indicater success/failure. + * Tue Dec 3 2019 Sjoerd Mullender - Removed the tunique property. The tunique property indicated that all values in the column had to be distinct. It was removed because diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -1512,7 +1512,7 @@ Tputvalue(BAT *b, BUN p, const void *v, #endif } } else { - ATOMputFIX(b->ttype, Tloc(b, p), v); + return ATOMputFIX(b->ttype, Tloc(b, p), v); } return GDK_SUCCEED; } diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c --- a/gdk/gdk_atoms.c +++ b/gdk/gdk_atoms.c @@ -118,16 +118,24 @@ hgeHash(const hge *v) /* * @+ Standard Atoms */ -static int +static gdk_return batFix(const bat *b) { - return BBPretain(*b); + if (!is_bat_nil(*b) && BBPretain(*b) == 0) { + GDKerror("batFix failed\n"); + return GDK_FAIL; + } + return GDK_SUCCEED; } -static int +static gdk_return batUnfix(const bat *b) { - return BBPrelease(*b); + if (!is_bat_nil(*b) && BBPrelease(*b) < 0) { + GDKerror("batUnfix failed\n"); + return GDK_FAIL; + } + return GDK_SUCCEED; } /* @@ -1232,8 +1240,8 @@ atomDesc BATatoms[MAXATOMS] = { .atomWrite = (gdk_return (*)(const void *, stream *, size_t)) batWrite, .atomCmp = (int (*)(const void *, const void *)) intCmp, .atomHash = (BUN (*)(const void *)) intHash, - .atomFix = (int (*)(const void *)) batFix, - .atomUnfix = (int (*)(const void *)) batUnfix, + .atomFix = (gdk_return (*)(const void *)) batFix, + .atomUnfix = (gdk_return (*)(const void *)) batUnfix, }, [TYPE_int] = { .name = "int", diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h --- a/gdk/gdk_atoms.h +++ b/gdk/gdk_atoms.h @@ -50,8 +50,8 @@ typedef struct { int (*atomCmp) (const void *v1, const void *v2); BUN (*atomHash) (const void *v); /* optional functions */ - int (*atomFix) (const void *atom); - int (*atomUnfix) (const void *atom); + gdk_return (*atomFix) (const void *atom); + gdk_return (*atomUnfix) (const void *atom); /* varsized atom-only ADT functions */ var_t (*atomPut) (Heap *, var_t *off, const void *src); @@ -266,8 +266,8 @@ gdk_export const ptr ptr_nil; #define ATOMvarsized(t)(BATatoms[t].atomPut != NULL) #define ATOMlinear(t) BATatoms[t].linear #define ATOMtype(t)((t) == TYPE_void ? TYPE_oid : (t)) -#define ATOMfix(t,v) do if (BATatoms[t].atomFix) BATatoms[t].atomFix(v); while (0) -#define ATOMunfix(t,v) do if (BATatoms[t].atomUnfix) BATatoms[t].atomUnfix(v); while (0) +#define ATOMfix(t,v) (BATatoms[t].atomFix ? BATatoms[t].atomFix(v) : GDK_SUCCEED) +#define ATOMunfix(t,v) (BATatoms[t].atomUnfix ? BATatoms[t].atomUnfix(v) : GDK_SUCCEED) /* The base type is the storage type if the comparison function, the * hash function, and the nil value are the same as those of the @@ -296,11 +296,15 @@ ATOMputVAR(int type, Heap *heap, var_t * } -static inline void +static inline gdk_return __attribute__((__warn_unused_result__)) ATOMputFIX(int type, void *dst, const void *src) { + gdk_return rc; + assert(BATatoms[type].atomPut == NULL); - ATOMfix(type, src); + rc = ATOMfix(type, src); + if
MonetDB: default - Merged with Jun2020
Changeset: 96de754a8e1d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=96de754a8e1d Modified Files: sql/server/rel_select.c sql/server/rel_unnest.c sql/test/subquery/Tests/subquery4.stable.out Branch: default Log Message: Merged with Jun2020 ___ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list
MonetDB: default - Merged with Jun2020
Changeset: 0c865bfdba81 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0c865bfdba81 Modified Files: sql/server/rel_psm.c sql/server/rel_rel.c sql/server/rel_rel.h sql/server/rel_select.c sql/server/rel_unnest.c sql/test/miscellaneous/Tests/simple_selects.sql sql/test/miscellaneous/Tests/simple_selects.stable.err sql/test/pg_regress/Tests/alter_table.stable.err sql/test/subquery/Tests/subquery4.sql sql/test/subquery/Tests/subquery4.stable.err sql/test/subquery/Tests/subquery4.stable.out tools/merovingian/daemon/argvcmds.c tools/merovingian/daemon/controlrunner.c tools/merovingian/daemon/discoveryrunner.c tools/merovingian/daemon/merovingian.c tools/merovingian/daemon/multiplex-funnel.c tools/merovingian/daemon/multiplex-funnel.h Branch: default Log Message: Merged with Jun2020 diffs (truncated from 685 to 300 lines): diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c --- a/sql/server/rel_psm.c +++ b/sql/server/rel_psm.c @@ -105,8 +105,11 @@ psm_set_exp(sql_query *query, dnode *n) if (!rel_val) return NULL; - if (!is_project(rel_val->op) || dlist_length(vars) != list_length(rel_val->exps)) + if (!is_project(rel_val->op)) + return sql_error(sql, 02, SQLSTATE(42000) "SET: The subquery is not a projection"); + if (dlist_length(vars) != list_length(rel_val->exps)) return sql_error(sql, 02, SQLSTATE(42000) "SET: Number of variables not equal to number of supplied values"); + rel_val = rel_zero_or_one(sql, rel_val, ek); b = sa_list(sql->sa); append(b, exp_rel(sql, rel_val)); @@ -125,19 +128,12 @@ psm_set_exp(sql_query *query, dnode *n) tpe = stack_find_type(sql, vname); } - if (!exp_name(v)) + level = stack_find_frame(sql, vname); + if (!exp_name(v)) exp_label(sql->sa, v, ++sql->label); v = exp_ref(sql->sa, v); - - level = stack_find_frame(sql, vname); - v = rel_check_type(sql, tpe, rel_val, v, type_cast); - if (!v) + if (!(v = rel_check_type(sql, tpe, rel_val, v, type_cast))) return NULL; - if (v->card > CARD_AGGR) { - sql_subfunc *zero_or_one = sql_bind_func(sql->sa, sql->session->schema, "zero_or_one", exp_subtype(v), NULL, F_AGGR); - assert(zero_or_one); - v = exp_aggr1(sql->sa, v, zero_or_one, 0, 0, CARD_ATOM, has_nil(v)); - } append(b, exp_set(sql->sa, vname, v, level)); } res = exp_rel(sql, rel_psm_block(sql->sa, b)); @@ -520,6 +516,11 @@ rel_select_into( sql_query *query, symbo r = rel_subquery(query, NULL, sq, ek); if (!r) return NULL; + if (!is_project(r->op)) + return sql_error(sql, 02, SQLSTATE(42000) "SELECT INTO: The subquery is not a projection"); + if (list_length(r->exps) != dlist_length(into)) + return sql_error(sql, 02, SQLSTATE(21S01) "SELECT INTO: number of values doesn't match number of variables to set"); + r = rel_zero_or_one(sql, r, ek); nl = sa_list(sql->sa); append(nl, exp_rel(sql, r)); for (m = r->exps->h, n = into->h; m && n; m = m->next, n = n->next) { @@ -530,15 +531,12 @@ rel_select_into( sql_query *query, symbo if (!stack_find_var(sql, nme)) return sql_error(sql, 02, SQLSTATE(42000) "SELECT INTO: variable '%s' unknown", nme); - /* dynamic check for single values */ - if (v->card > CARD_AGGR) { - sql_subfunc *zero_or_one = sql_bind_func(sql->sa, sql->session->schema, "zero_or_one", exp_subtype(v), NULL, F_AGGR); - assert(zero_or_one); - v = exp_aggr1(sql->sa, v, zero_or_one, 0, 0, CARD_ATOM, has_nil(v)); - } tpe = stack_find_type(sql, nme); level = stack_find_frame(sql, nme); - if (!v || !(v = rel_check_type(sql, tpe, r, v, type_equal))) + if (!exp_name(v)) + exp_label(sql->sa, v, ++sql->label); + v = exp_ref(sql->sa, v); + if (!(v = rel_check_type(sql, tpe, r, v, type_equal))) return NULL; v = exp_set(sql->sa, nme, v, level); list_append(nl, v); diff --git a/sql/server/rel_rel.c b/sql/server/rel_rel.c --- a/sql/server/rel_rel.c +++