[prev in list] [next in list] [prev in thread] [next in thread] 

List:       monetdb-checkins
Subject:    MonetDB: Oct2020 - For case and coaleasce, ensure there is alway...
From:       Pedro Ferreira <commits+pedro.ferreira=monetdbsolutions.com () monetdb ! org>
Date:       2020-12-30 11:33:38
Message-ID: hg.39d4ebab7f05.1609328018.6315528441665844383 () monetdb-vm0 ! spin-off ! cwi ! nl
[Download RAW message or body]

Changeset: 39d4ebab7f05 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=39d4ebab7f05
Modified Files:
	sql/server/rel_select.c
	sql/test/SQLancer/Tests/sqlancer09.sql
	sql/test/SQLancer/Tests/sqlancer09.stable.err
	sql/test/SQLancer/Tests/sqlancer09.stable.out
Branch: Oct2020
Log Message:

For case and coaleasce, ensure there is always a projection, so there won't be \
mismatches on the code generation


diffs (61 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
@@ -3867,6 +3867,10 @@ rel_case_exp(sql_query *query, sql_rel *
 {
 	dlist *l = se->data.lval;
 
+	/* Ensure there is always a projection */
+	if (rel && !*rel)
+		*rel = rel_project(query->sql->sa, NULL, append(new_exp_list(query->sql->sa), \
exp_atom_bool(query->sql->sa, 1))); +
 	if (se->token == SQL_COALESCE) {
 		return rel_complex_case(query, rel, l, f, "coalesce");
 	} else if (se->token == SQL_NULLIF) {
diff --git a/sql/test/SQLancer/Tests/sqlancer09.sql \
                b/sql/test/SQLancer/Tests/sqlancer09.sql
--- a/sql/test/SQLancer/Tests/sqlancer09.sql
+++ b/sql/test/SQLancer/Tests/sqlancer09.sql
@@ -94,3 +94,14 @@ SELECT 1 FROM (SELECT 1 FROM v0) AS v0(v
 -- Disable rel_simplify_ifthenelse optimizer
 SELECT 1 FROM (SELECT 1 FROM v0) AS v0(v0) inner join t1 ON 1 BETWEEN 2 AND (CASE \
WHEN 1 BETWEEN 2 AND 3 THEN 2 END);  ROLLBACK;
+
+START TRANSACTION;
+CREATE TABLE "sys"."t2" ("c0" BOOLEAN NOT NULL DEFAULT false, CONSTRAINT \
"t2_c0_pkey" PRIMARY KEY ("c0")); +
+INSERT INTO t2(c0) VALUES((((((((least(r' ]', r'3''')) IS NULL)OR((((TIMESTAMP \
'1969-12-20 19:22:32') BETWEEN SYMMETRIC (TIMESTAMP '1969-12-29 05:03:02') AND \
(TIMESTAMP '1970-01-14 15:38:43'))OR +(CASE FALSE WHEN FALSE THEN TRUE WHEN TRUE THEN \
TRUE WHEN FALSE THEN FALSE WHEN FALSE THEN TRUE ELSE TRUE END)))))OR \
+(COALESCE((TIMESTAMP '1969-12-11 14:58:21') BETWEEN SYMMETRIC (TIMESTAMP '1970-01-09 \
21:56:14') AND (TIMESTAMP '1970-01-01 01:00:14'),  +((0.26488915)>(1.345373227E9)), \
sql_min(FALSE, TRUE)))))AND("isauuid"(r'45456452')))), (TRUE); +
+INSERT INTO t2 VALUES (COALESCE(1 BETWEEN 2 AND 3, 1));
+ROLLBACK;
diff --git a/sql/test/SQLancer/Tests/sqlancer09.stable.err \
                b/sql/test/SQLancer/Tests/sqlancer09.stable.err
--- a/sql/test/SQLancer/Tests/sqlancer09.stable.err
+++ b/sql/test/SQLancer/Tests/sqlancer09.stable.err
@@ -5,6 +5,10 @@ stderr of test 'sqlancer09` in directory
 # 14:35:03 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" \
"--host=/var/tmp/mtest-493376" "--port=30980"  # 14:35:03 >  
 
+MAPI  = (monetdb) /var/tmp/mtest-133412/.s.monetdb.36570
+QUERY = INSERT INTO t2 VALUES (COALESCE(1 BETWEEN 2 AND 3, 1));
+ERROR = !INSERT INTO: PRIMARY KEY constraint 't2.t2_c0_pkey' violated
+CODE  = 40002
 
 # 14:35:03 >  
 # 14:35:03 >  "Done."
diff --git a/sql/test/SQLancer/Tests/sqlancer09.stable.out \
                b/sql/test/SQLancer/Tests/sqlancer09.stable.out
--- a/sql/test/SQLancer/Tests/sqlancer09.stable.out
+++ b/sql/test/SQLancer/Tests/sqlancer09.stable.out
@@ -101,6 +101,11 @@ stdout of test 'sqlancer09` in directory
 % tinyint # type
 % 1 # length
 #ROLLBACK;
+#START TRANSACTION;
+#CREATE TABLE "sys"."t2" ("c0" BOOLEAN NOT NULL DEFAULT false, CONSTRAINT \
"t2_c0_pkey" PRIMARY KEY ("c0")); +#INSERT INTO t2(c0) VALUES((((((((least(r' ]', \
r'3''')) IS NULL)OR((((TIMESTAMP '1969-12-20 19:22:32') BETWEEN SYMMETRIC (TIMESTAMP \
'1969-12-29 05:03:02') AND (TIMESTAMP '1970-01-14 15:38:43'))OR(CASE FALSE WHEN FALSE \
THEN TRUE WHEN TRUE THEN TRUE WHEN FALSE THEN FALSE WHEN FALSE THEN TRUE ELSE TRUE \
END)))))OR(COALESCE((TIMESTAMP '1969-12-11 14:58:21') BETWEEN SYMMETRIC (TIMESTAMP \
'1970-01-09 21:56:14') AND (TIMESTAMP '1970-01-01 01:00:14'), \
((0.26488915)>(1.345373227E9)), sql_min(FALSE, \
TRUE)))))AND("isauuid"(r'45456452')))), (TRUE); +[ 2	]
+#ROLLBACK;
 
 # 14:35:03 >  
 # 14:35:03 >  "Done."
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic