Changeset: 660b5b25a25c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=660b5b25a25c
Modified Files:
        sql/server/rel_select.c
        sql/test/SQLancer/Tests/sqlancer08.sql
        sql/test/SQLancer/Tests/sqlancer08.stable.out
Branch: octbugs
Log Message:

Making SQLancer happy. Swap input parameters for comparison if it is the case 
in projections (as it happens in selections). With this, rel_convert_types will 
output the same type for both in case they have different input parameters


diffs (75 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
@@ -2213,12 +2213,19 @@ rel_logical_value_exp(sql_query *query, 
                if (!rs)
                        return NULL;
 
+               if (!exp_is_rel(ls) && !exp_is_rel(rs) && ls->card < rs->card) {
+                       sql_exp *swap = ls; /* has to swap parameters like in 
the rel_logical_exp case */
+                       ls = rs;
+                       rs = swap;
+                       cmp_type = swap_compare(cmp_type);
+               }
+
                if (rel_binop_check_types(sql, rel ? *rel : NULL, ls, rs, 0) < 
0)
                        return NULL;
                if (exp_is_null(ls) && exp_is_null(rs))
                        return exp_atom(sql->sa, atom_general(sql->sa, 
sql_bind_localtype("bit"), NULL));
 
-               ls = exp_compare_func(sql, ls, rs, 
compare_func(compare_str2type(compare_op), quantifier?0:need_not), quantifier);
+               ls = exp_compare_func(sql, ls, rs, compare_func(cmp_type, 
quantifier?0:need_not), quantifier);
                if (need_not && quantifier)
                        ls = rel_unop_(sql, NULL, ls, NULL, "not", card_value);
                return ls;
diff --git a/sql/test/SQLancer/Tests/sqlancer08.sql 
b/sql/test/SQLancer/Tests/sqlancer08.sql
--- a/sql/test/SQLancer/Tests/sqlancer08.sql
+++ b/sql/test/SQLancer/Tests/sqlancer08.sql
@@ -202,3 +202,15 @@ START TRANSACTION;
 create view v7(vc0, vc1) as (select all 56, replace(r'0.0074401190660642325', 
"insert"(r'0.9471086251830542', null, 1872651914, r'(Ga_'), r'2]vK') where not 
(not (false))) with check option;
 select 1 from v7 where not (((cast(scale_up(4751, -1823537248) as 
string(86)))not like(v7.vc1)));
 ROLLBACK;
+
+START TRANSACTION;
+CREATE TABLE "sys"."t1" ("tc0" BIGINT);
+COPY 4 RECORDS INTO "sys"."t1" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+284462307
+1404201729
+1549521937
+452608969
+
+SELECT 1 FROM t1 WHERE ('1255780658' > (least(1287317023, ((0.8056138 + 
t1.tc0) ))));
+SELECT CAST(SUM(count) AS BIGINT) FROM (SELECT CAST(('1255780658' > 
(least(1287317023, ((0.8056138 + t1.tc0))))) AS INT) as count FROM t1) as res;
+ROLLBACK;
diff --git a/sql/test/SQLancer/Tests/sqlancer08.stable.out 
b/sql/test/SQLancer/Tests/sqlancer08.stable.out
--- a/sql/test/SQLancer/Tests/sqlancer08.stable.out
+++ b/sql/test/SQLancer/Tests/sqlancer08.stable.out
@@ -275,6 +275,28 @@ stdout of test 'sqlancer08` in directory
 % tinyint # type
 % 1 # length
 #ROLLBACK;
+#START TRANSACTION;
+#CREATE TABLE "sys"."t1" ("tc0" BIGINT);
+#COPY 4 RECORDS INTO "sys"."t1" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+#284462307
+#1404201729
+#1549521937
+#452608969
+[ 4    ]
+#SELECT 1 FROM t1 WHERE ('1255780658' > (least(1287317023, ((0.8056138 + 
t1.tc0) ))));
+% .%1 # table_name
+% %1 # name
+% tinyint # type
+% 1 # length
+[ 1    ]
+[ 1    ]
+#SELECT CAST(SUM(count) AS BIGINT) FROM (SELECT CAST(('1255780658' > 
(least(1287317023, ((0.8056138 + t1.tc0))))) AS INT) as count FROM t1) as res;
+% .%3 # table_name
+% %3 # name
+% bigint # type
+% 1 # length
+[ 2    ]
+#ROLLBACK;
 
 # 11:38:36 >  
 # 11:38:36 >  "Done."
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to