Changeset: 342c88cc7309 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=342c88cc7309 Modified Files: sql/backends/monet5/rel_bin.c sql/common/sql_types.c sql/server/rel_select.c sql/server/sql_semantic.c sql/test/SQLancer/Tests/sqlancer01.sql sql/test/analytics/Tests/analytics07.stable.err sql/test/analytics/Tests/analytics07.stable.out Branch: default Log Message:
Merge with Jun2020 branch. diffs (247 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 @@ -1107,7 +1107,9 @@ exp_bin(backend *be, sql_exp *e, stmt *l r2 = stmt_project(be, sel, r2); sel = NULL; } - s = stmt_uselect2(be, column(be, l), r, r2, (comp_type)e->flag, sel, is_anti(e)); + if (l->nrcols == 0) + l = stmt_const(be, bin_first_column(be, left), l); + s = stmt_uselect2(be, l, r, r2, (comp_type)e->flag, sel, is_anti(e)); } } else { /* value compare or select */ 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 @@ -419,10 +419,10 @@ subtype2string2(sql_subtype *tpe) //dist switch (tpe->type->eclass) { case EC_SEC: - snprintf(buf, BUFSIZ, "BIGINT"); + snprintf(buf, BUFSIZ, "INTERVAL SECOND"); break; case EC_MONTH: - snprintf(buf, BUFSIZ, "INT"); + snprintf(buf, BUFSIZ, "INTERVAL MONTH"); break; case EC_CHAR: case EC_STRING: 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 @@ -4698,7 +4698,7 @@ calculate_window_bound(sql_query *query, if (!(bclass == EC_NUM || EC_INTERVAL(bclass) || bclass == EC_DEC || bclass == EC_FLT)) return sql_error(sql, 02, SQLSTATE(42000) "%s offset must be of a countable SQL type", bound_desc); if ((frame_type == FRAME_ROWS || frame_type == FRAME_GROUPS) && bclass != EC_NUM) { - char *err = subtype2string(bt); + char *err = subtype2string2(bt); if (!err) return sql_error(sql, 02, SQLSTATE(HY013) MAL_MALLOC_FAIL); (void) sql_error(sql, 02, SQLSTATE(42000) "Values on %s boundary on %s frame can't be %s type", bound_desc, @@ -4716,7 +4716,7 @@ calculate_window_bound(sql_query *query, if (bclass != EC_DEC && iet->type->eclass == EC_DEC) return sql_error(sql, 02, SQLSTATE(42000) "Values on %s boundary aren't decimals while on input are", bound_desc); if (bclass != EC_SEC && iet->type->eclass == EC_TIME) { - char *err = subtype2string(iet); + char *err = subtype2string2(iet); if (!err) return sql_error(sql, 02, SQLSTATE(HY013) MAL_MALLOC_FAIL); (void) sql_error(sql, 02, SQLSTATE(42000) "For %s input the %s boundary must be an interval type up to the day", err, bound_desc); @@ -4724,7 +4724,7 @@ calculate_window_bound(sql_query *query, return NULL; } if (EC_INTERVAL(bclass) && !EC_TEMP(iet->type->eclass)) { - char *err = subtype2string(iet); + char *err = subtype2string2(iet); if (!err) return sql_error(sql, 02, SQLSTATE(HY013) MAL_MALLOC_FAIL); (void) sql_error(sql, 02, SQLSTATE(42000) "For %s input the %s boundary must be an interval type", err, bound_desc); diff --git a/sql/server/sql_semantic.c b/sql/server/sql_semantic.c --- a/sql/server/sql_semantic.c +++ b/sql/server/sql_semantic.c @@ -344,7 +344,8 @@ symbol2string(mvc *sql, symbol *se, int sname = sql->session->schema->base.name; for (aux = ops; aux; aux = aux->next) nargs++; - inputs = GDKzalloc(nargs * sizeof(char**)); + if (!(inputs = GDKzalloc(nargs * sizeof(char**)))) + return NULL; for (aux = ops; aux; aux = aux->next) { if (!(inputs[i] = symbol2string(sql, aux->data.sym, expression, err))) { @@ -480,7 +481,7 @@ symbol2string(mvc *sql, symbol *se, int dlist *dl = se->data.lval; char *val = NULL, *tpe = NULL, *res; - if (!(val = symbol2string(sql, dl->h->data.sym, expression, err)) || !(tpe = subtype2string(&dl->h->next->data.typeval))) { + if (!(val = symbol2string(sql, dl->h->data.sym, expression, err)) || !(tpe = subtype2string2(&dl->h->next->data.typeval))) { _DELETE(val); _DELETE(tpe); return NULL; 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 @@ -228,6 +228,69 @@ SELECT v0.c0 FROM v0 WHERE (v0.c1) NOT B --empty ROLLBACK; +START TRANSACTION; +CREATE TABLE t0 (c0 integer DEFAULT CAST(0 AS INT)); +ROLLBACK; + +START TRANSACTION; -- Bug 6903 and 6904 +CREATE TABLE "sys"."t0" ("c0" DOUBLE, "c1" VARCHAR(496)); +COPY 20 RECORDS INTO "sys"."t0" FROM stdin USING DELIMITERS E'\t',E'\n','"'; +0.1438664733406536 NULL +0.1765302987566959 NULL +NULL "0.6278315174254069" +0.9937940991911638 "470810.02006337716" +0.925750874406328 " \\Z᳣s}LfFQk呗8Mßßl07VXpgoVDy\015'X\n}呗x逖n\015>⎑s%cQyIQ" +NULL "0.17744327397271142" +NULL "y" +NULL "緦좺VDOKB " +1511423462 "470810.02006337716" +0.5249207035059663 "470810.02006337716" +1 "470810.02006337716" +0.3762066043983153 "470810.02006337716" +-939120682 "c2lT^9BY0smjöA罀A&ß14_[#*r" +0.522051822144801 "0.008675985" +0.5347718465897517 "c2lt^9by0smjöa罀a&ß14_[#*r" +NULL "true" +NULL "-844489501" +NULL "0.44968215744290607" +NULL ".v" +NULL "-174251119" + +SELECT ALL CAST(VAR_SAMP(ALL abs(CAST(t0.c1 AS INT))) AS INT) FROM t0 GROUP BY CAST(t0.c1 AS INT), t0.c1; +SELECT ALL 0.1002352, AVG(ALL t0.c0) FROM t0 GROUP BY CAST(t0.c0 AS STRING(799)), 0.4665444117594173, ((sql_min(+ ("locate"('', 'F', 150648381)), ((((-1039870396)||(390810869)))*(length(r'u')))))>>(CAST(0.588018201374832 AS INT))); +ROLLBACK; + +START TRANSACTION; -- Bug 6905 +CREATE TABLE "sys"."t0" ("c0" INTEGER,"c1" DOUBLE); +COPY 15 RECORDS INTO "sys"."t0" FROM stdin USING DELIMITERS E'\t',E'\n','"'; +-1498252621 -1498252621 +0 NULL +-539579569 -539579569 +-108613919 NULL +0 0 +8 NULL +1783007739 NULL +498706403 NULL +0 0.6103170716911988 +1493854316 0.6198781779645515 +-1608947797 1 +1 0.8356779050811012 +-101868623 0.16442926747225173 +1493854316 -1498252621 +1 0.9401903184230552 + +SELECT t0.c0 FROM t0 WHERE (0.9952398693354088) IN (t0.c1, t0.c1); + --empty (this one is right) +SELECT ALL t0.c0 FROM t0 WHERE NOT ((0.9952398693354088) IN (t0.c1, t0.c1)); + -- 10 rows (this one is right) +SELECT t0.c0 FROM t0 WHERE ((0.9952398693354088) IN (t0.c1, t0.c1)) IS NULL; + -- 0 + -- -108613919 + -- 8 + -- 1783007739 + -- 498706403 +ROLLBACK; + DROP TABLE tbl_ProductSales; DROP TABLE another_T; DROP TABLE integers; diff --git a/sql/test/analytics/Tests/analytics07.stable.err b/sql/test/analytics/Tests/analytics07.stable.err --- a/sql/test/analytics/Tests/analytics07.stable.err +++ b/sql/test/analytics/Tests/analytics07.stable.err @@ -34,7 +34,7 @@ ERROR = !The PRECEDING boundary must be CODE = 42000 MAPI = (monetdb) /var/tmp/mtest-4630/.s.monetdb.34662 QUERY = select count(*) over (order by aa range between interval '3' month preceding and interval '5' month following) from testintervals3; --error, for time columns month intervals are not allowed -ERROR = !For time(1) input the PRECEDING boundary must be an interval type up to the day +ERROR = !For time input the PRECEDING boundary must be an interval type up to the day CODE = 42000 # 11:59:18 > diff --git a/sql/test/analytics/Tests/analytics07.stable.out b/sql/test/analytics/Tests/analytics07.stable.out --- a/sql/test/analytics/Tests/analytics07.stable.out +++ b/sql/test/analytics/Tests/analytics07.stable.out @@ -43,8 +43,8 @@ stdout of test 'analytics07` in director # count(*) over (order by aa range between interval '1' month preceding and current row), # count(*) over (order by aa range between current row and interval '30000' second following), # count(*) over (order by aa range between unbounded preceding and unbounded following) from testintervals; -% sys.%11, sys.%14, sys.%17, sys.%22, sys.%25, sys.%30 # table_name -% %11, %14, %17, %22, %25, %30 # name +% sys.%10, sys.%20, sys.%30, sys.%40, sys.%50, sys.%60 # table_name +% %10, %20, %30, %40, %50, %60 # name % bigint, bigint, bigint, bigint, bigint, bigint # type % 1, 1, 1, 1, 1, 1 # length [ 1, 1, 7, 1, 1, 7 ] @@ -59,8 +59,8 @@ stdout of test 'analytics07` in director # count(*) over (order by aa range between interval '2' month preceding and interval '1' month following), # count(*) over (order by aa range between interval '0' second preceding and interval '0' second following), # count(*) over (order by aa range between interval '2629800' second preceding and interval '2629800' second following), -% sys.%11, sys.%14, sys.%17, sys.%22, sys.%25, sys.%30 # table_name -% %11, %14, %17, %22, %25, %30 # name +% sys.%10, sys.%20, sys.%30, sys.%40, sys.%50, sys.%60 # table_name +% %10, %20, %30, %40, %50, %60 # name % bigint, bigint, bigint, bigint, bigint, bigint # type % 1, 1, 1, 1, 1, 1 # length [ 1, 1, 1, 1, 1, 1 ] @@ -75,8 +75,8 @@ stdout of test 'analytics07` in director # count(*) over (order by aa desc range between interval '2' month preceding and interval '1' month following), # count(*) over (order by aa desc range between interval '0' second preceding and interval '0' second following), # count(*) over (order by aa desc range between interval '2629800' second preceding and interval '2629800' second following), -% sys.%11, sys.%14, sys.%17, sys.%22, sys.%25, sys.%30 # table_name -% %11, %14, %17, %22, %25, %30 # name +% sys.%10, sys.%20, sys.%30, sys.%40, sys.%50, sys.%60 # table_name +% %10, %20, %30, %40, %50, %60 # name % bigint, bigint, bigint, bigint, bigint, bigint # type % 1, 1, 1, 1, 1, 1 # length [ 1, 1, 1, 1, 1, 1 ] @@ -91,8 +91,8 @@ stdout of test 'analytics07` in director # count(*) over (order by aa range between interval '2' month preceding and interval '1' month following), # count(*) over (order by aa range between interval '0' second preceding and interval '0' second following), # count(*) over (order by aa range between interval '2629800' second preceding and interval '2629800' second following), -% sys.%11, sys.%14, sys.%17, sys.%22, sys.%25, sys.%30 # table_name -% %11, %14, %17, %22, %25, %30 # name +% sys.%10, sys.%20, sys.%30, sys.%40, sys.%50, sys.%60 # table_name +% %10, %20, %30, %40, %50, %60 # name % bigint, bigint, bigint, bigint, bigint, bigint # type % 1, 1, 1, 1, 1, 1 # length [ 1, 1, 1, 1, 1, 1 ] @@ -107,8 +107,8 @@ stdout of test 'analytics07` in director # count(*) over (order by aa desc range between interval '2' month preceding and interval '1' month following), # count(*) over (order by aa desc range between interval '0' second preceding and interval '0' second following), # count(*) over (order by aa desc range between interval '2629800' second preceding and interval '2629800' second following), -% sys.%11, sys.%14, sys.%17, sys.%22, sys.%25, sys.%30 # table_name -% %11, %14, %17, %22, %25, %30 # name +% sys.%10, sys.%20, sys.%30, sys.%40, sys.%50, sys.%60 # table_name +% %10, %20, %30, %40, %50, %60 # name % bigint, bigint, bigint, bigint, bigint, bigint # type % 1, 1, 1, 1, 1, 1 # length [ 1, 1, 1, 1, 1, 1 ] @@ -122,8 +122,8 @@ stdout of test 'analytics07` in director # count(*) over (order by aa range between interval '3' hour preceding and interval '3' hour following), # count(*) over (order by aa range between interval '60' minute preceding and interval '60' minute following), # count(*) over (order by aa range between current row and current row) from testintervals3; -% sys.%7, sys.%12, sys.%15, sys.%20 # table_name -% %7, %12, %15, %20 # name +% sys.%10, sys.%20, sys.%30, sys.%40 # table_name +% %10, %20, %30, %40 # name % bigint, bigint, bigint, bigint # type % 1, 1, 1, 1 # length [ 1, 2, 1, 1 ] @@ -137,8 +137,8 @@ stdout of test 'analytics07` in director # count(*) over (order by aa desc range between interval '3' hour preceding and interval '3' hour following), # count(*) over (order by aa desc range between interval '60' minute preceding and interval '60' minute following), # count(*) over (order by aa desc range between current row and current row) from testintervals3; -% sys.%7, sys.%12, sys.%15, sys.%20 # table_name -% %7, %12, %15, %20 # name +% sys.%10, sys.%20, sys.%30, sys.%40 # table_name +% %10, %20, %30, %40 # name % bigint, bigint, bigint, bigint # type % 1, 1, 1, 1 # length [ 1, 2, 2, 1 ] _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list