Changeset: 1228d09e3953 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1228d09e3953
Modified Files:
sql/backends/monet5/rel_bin.c
Branch: unlock
Log Message:
merged
diffs (102 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
@@ -785,6 +785,11 @@ exp2bin_casewhen(backend *be, sql_exp *f
if (!l)
l = bin_first_column(be, left);
case_when = stmt_const(be, l, case_when);
+ if (case_when)
+ case_when->cand = isel;
+ }
+ if (!single_value && isel && !case_when->cand) {
+ case_when = stmt_project(be, isel, case_when);
case_when->cand = isel;
}
@@ -811,11 +816,27 @@ exp2bin_casewhen(backend *be, sql_exp *f
return NULL;
if (next_cond) {
stmt *l = case_when;
- assert(!es->cand || !l->cand || es->cand == l->cand);
- if (es->cand && !l->cand)
- l = stmt_project(be, es->cand, case_when);
- else if (l->cand && !es->cand)
- es = stmt_project(be, l->cand, es);
+ if (!single_value) {
+ if (rsel && isel) {
+ assert(l->cand == isel);
+ l = stmt_project(be, rsel, l);
+ l->cand = nsel;
+ }
+
+ if (es->cand && !l->cand) {
+ assert(es->cand == rsel);
+ l = stmt_project(be, es->cand, l);
+ l->cand = es->cand;
+ } else if (nsel && !es->cand) {
+ es = stmt_project(be, nsel, es);
+ es->cand = nsel;
+ if (!l->cand) {
+ l = stmt_project(be, nsel, l);
+ l->cand = nsel;
+ }
+ }
+ assert(l->cand == es->cand);
+ }
es = stmt_binop(be, l, es, NULL, cmp);
}
if (!single_value) {
diff --git a/sql/test/SQLancer/Tests/sqlancer10.test
b/sql/test/SQLancer/Tests/sqlancer10.test
--- a/sql/test/SQLancer/Tests/sqlancer10.test
+++ b/sql/test/SQLancer/Tests/sqlancer10.test
@@ -270,3 +270,50 @@ SELECT CAST(SUM(count) AS BIGINT) FROM (
----
2
+statement ok
+ROLLBACK
+
+statement ok
+START TRANSACTION
+
+statement ok
+CREATE TABLE "t0" ("c0" DECIMAL(18,3) NOT NULL,"c3" INT,CONSTRAINT
"t0_c0_unique" UNIQUE ("c0"),CONSTRAINT "t0_c3_c0_unique" UNIQUE ("c3", "c0"))
+
+statement ok
+INSERT INTO "t0" VALUES (0.000, NULL), (0.587, 4)
+
+statement ok
+CREATE TABLE "t2" ("c1" INT NOT NULL,"c2" DECIMAL(18,3),"c3" INT,"c4"
BIGINT,CONSTRAINT "t2_c1_pkey" PRIMARY KEY ("c1"),CONSTRAINT "t2_c1_unique"
UNIQUE ("c1"),
+CONSTRAINT "t2_c2_unique" UNIQUE ("c2"),CONSTRAINT "t2_c1_c2_unique" UNIQUE
("c1", "c2"))
+
+statement ok
+INSERT INTO "t2" VALUES (2, 0.639, 3, 1), (0, NULL, NULL, 0), (8, NULL, NULL,
5)
+
+query I rowsort
+SELECT 1 FROM t0, t2 GROUP BY t2.c1
+----
+1
+1
+1
+
+query I rowsort
+SELECT 1 FROM t0, t2 GROUP BY t2.c1 HAVING ((((SELECT FALSE WHERE FALSE)
EXCEPT (SELECT 'a'))) = FALSE) IS NULL
+----
+1
+1
+1
+
+query I rowsort
+SELECT 1 FROM t0, t2 GROUP BY t2.c1 HAVING (((SELECT FALSE WHERE FALSE) EXCEPT
(SELECT 'a'))) = FALSE
+UNION ALL
+SELECT 1 FROM t0, t2 GROUP BY t2.c1 HAVING NOT ((((SELECT FALSE WHERE FALSE)
EXCEPT (SELECT 'a'))) = FALSE)
+UNION ALL
+SELECT 1 FROM t0, t2 GROUP BY t2.c1 HAVING ((((SELECT FALSE WHERE FALSE)
EXCEPT (SELECT 'a'))) = FALSE) IS NULL
+----
+1
+1
+1
+
+statement ok
+ROLLBACK
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list