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

sqlancer crash and fix, ie don't forget to generate expressions for set relation


diffs (107 lines):

diff --git a/sql/server/rel_updates.c b/sql/server/rel_updates.c
--- a/sql/server/rel_updates.c
+++ b/sql/server/rel_updates.c
@@ -1258,7 +1258,7 @@ merge_into_table(sql_query *query, dlist
        char *sname = qname_schema(qname), *tname = qname_schema_object(qname);
        sql_schema *s = cur_schema(sql);
        sql_table *t = NULL;
-       sql_rel *bt, *joined, *join_rel = NULL, *extra_project, *insert = NULL, 
*upd_del = NULL, *res = NULL;
+       sql_rel *bt, *joined, *join_rel = NULL, *extra_project, *insert = NULL, 
*upd_del = NULL, *res = NULL, *no_tid = NULL;
        int processed = 0;
        const char *bt_name;
 
@@ -1363,7 +1363,9 @@ merge_into_table(sql_query *query, dlist
 
                        //project joined values which didn't match on the join 
and insert them
                        extra_project = rel_project(sql->sa, join_rel, 
rel_projections(sql, joined, NULL, 1, 0));
-                       extra_project = rel_setop(sql->sa, rel_dup(joined), 
extra_project, op_except);
+                       no_tid = rel_project(sql->sa, rel_dup(joined), 
rel_projections(sql, joined, NULL, 1, 0));
+                       extra_project = rel_setop(sql->sa, no_tid, 
extra_project, op_except);
+                       rel_setop_set_exps(sql, extra_project, 
rel_projections(sql, extra_project, NULL, 1, 0));
 
                        if (!(insert = merge_generate_inserts(query, t, 
extra_project, sts->h->data.lval, sts->h->next->data.sym)))
                                return NULL;
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
@@ -19,3 +19,38 @@ CREATE TABLE "t0" ("tc0" TINYINT NOT NUL
 update t0 set tc2 = 119, tc0 = cast(t0.tc0 as bigint);
 update t0 set tc2 = 119, tc0 = (least(+ (cast(least(0, t0.tc0) as bigint)), 
sign(scale_down(100, 1)))) where true;
 ROLLBACK;
+
+START TRANSACTION;
+CREATE TABLE "sys"."t0" ("c0" TIMESTAMP NOT NULL,"c1" DOUBLE,CONSTRAINT 
"t0_c0_pkey" PRIMARY KEY ("c0"),CONSTRAINT "t0_c0_unique" UNIQUE ("c0"));
+CREATE TABLE "sys"."t1" ("c0" DECIMAL(18,3));
+COPY 8 RECORDS INTO "sys"."t1" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+19522599.000
+0.638
+0.071
+12.000
+0.156
+0.902
+-546.000
+0.603
+
+CREATE TABLE "sys"."t2" ("c0" TIMESTAMP,"c1" DOUBLE);
+COPY 2 RECORDS INTO "sys"."t2" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+NULL   -869912003
+NULL   0.9641209077369987
+
+create view v0(vc0) as (with cte0(c0) as (with cte0(c0,c1) as (values 
(interval '2' day, ((null)%(0.3)))),
+cte1(c0,c1,c2,c3,c4) as (select all least(r'', r'2'), date '1970-01-13', 
((r'')ilike(r'OF먉_')),
+((-2)+(-3)), cast(true as string(105)) where false) select distinct cast(case 
1.1 when 0.2 then
+l1cte1.c1 when 0.4 then l1cte1.c1 when 1.03728474E9 then l1cte1.c1 when 0.2 
then l1cte1.c1 else l1cte1.c1 end as string)
+from t0 as l1t0, t1 as l1t1,cte0 as l1cte0,cte1 as l1cte1 where not 
(l1cte1.c2)) select distinct least(-1, l0t0.c1)
+from t1 as l0t1, t0 as l0t0,cte0 as l0cte0 where least(cast(l0cte0.c0 as 
boolean), true));
+
+merge into t0 using (select * from v0) as v0 on true when not matched then 
insert (c1, c0) values ((select 1 from t1), timestamp '1970-01-20 08:57:27');
+
+merge into t0 using (select * from v0) as v0 on ((r'>\nAH')not 
like(cast(scale_up(99, 0.1) as string(278))))
+when not matched then insert (c1, c0) values (((((abs(-5))%((select -3 from t1 
as l3t1, t2 as l3t2 where true))))
+>>((((values (1), (1)))>>((select distinct 2 from t1 as l3t1 where false))))), 
ifthenelse(abs(0.3) = 
+all(values ((select all 0.1 where true)), (case -1 when -3 then 0.1 
+when -2 then -5 end), (((1)>>(1)))), case when least(true, false) then 
greatest(timestamp '1970-01-15 21:14:28', timestamp '1970-01-02 15:11:23') end,
+nullif(timestamp '1970-01-20 08:57:27', sql_add(timestamp '1970-01-07 
21:19:48', interval '-3' day))));
+ROLLBACK;
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
@@ -30,6 +30,38 @@ stdout of test 'sqlancer09` in directory
 #update t0 set tc2 = 119, tc0 = (least(+ (cast(least(0, t0.tc0) as bigint)), 
sign(scale_down(100, 1)))) where true;
 [ 0    ]
 #ROLLBACK;
+#START TRANSACTION;
+#CREATE TABLE "sys"."t0" ("c0" TIMESTAMP NOT NULL,"c1" DOUBLE,CONSTRAINT 
"t0_c0_pkey" PRIMARY KEY ("c0"),CONSTRAINT "t0_c0_unique" UNIQUE ("c0"));
+#CREATE TABLE "sys"."t1" ("c0" DECIMAL(18,3));
+#COPY 8 RECORDS INTO "sys"."t1" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+#19522599.000
+#0.638
+#0.071
+#12.000
+#0.156
+#0.902
+#-546.000
+#0.603
+[ 8    ]
+#CREATE TABLE "sys"."t2" ("c0" TIMESTAMP,"c1" DOUBLE);
+#COPY 2 RECORDS INTO "sys"."t2" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+#NULL  -869912003
+#NULL  0.9641209077369987
+[ 2    ]
+#create view v0(vc0) as (with cte0(c0) as (with cte0(c0,c1) as (values 
(interval '2' day, ((null)%(0.3)))),
+#cte1(c0,c1,c2,c3,c4) as (select all least(r'', r'2'), date '1970-01-13', 
((r'')ilike(r'OF먉_')),
+#((-2)+(-3)), cast(true as string(105)) where false) select distinct cast(case 
1.1 when 0.2 then
+#l1cte1.c1 when 0.4 then l1cte1.c1 when 1.03728474E9 then l1cte1.c1 when 0.2 
then l1cte1.c1 else l1cte1.c1 end as string)
+#from t0 as l1t0, t1 as l1t1,cte0 as l1cte0,cte1 as l1cte1 where not 
(l1cte1.c2)) select distinct least(-1, l0t0.c1)
+#merge into t0 using (select * from v0) as v0 on true when not matched then 
insert (c1, c0) values ((select 1 from t1), timestamp '1970-01-20 08:57:27');
+[ 0    ]
+#merge into t0 using (select * from v0) as v0 on ((r'>\nAH')not 
like(cast(scale_up(99, 0.1) as string(278))))
+#when not matched then insert (c1, c0) values (((((abs(-5))%((select -3 from 
t1 as l3t1, t2 as l3t2 where true))))
+#>>((((values (1), (1)))>>((select distinct 2 from t1 as l3t1 where 
false))))), ifthenelse(abs(0.3) = 
+#all(values ((select all 0.1 where true)), (case -1 when -3 then 0.1 
+#when -2 then -5 end), (((1)>>(1)))), case when least(true, false) then 
greatest(timestamp '1970-01-15 21:14:28', timestamp '1970-01-02 15:11:23') end,
+[ 0    ]
+#ROLLBACK;
 
 # 14:35:03 >  
 # 14:35:03 >  "Done."
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to