Changeset: 89151dc8f7fc for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=89151dc8f7fc Modified Files: sql/server/rel_select.c sql/test/SQLancer/Tests/sqlancer02.sql sql/test/SQLancer/Tests/sqlancer02.stable.out Branch: Jun2020 Log Message:
Making SQLancer happy, make sure the arguments for sql_max and sql_min are of the same type diffs (79 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 @@ -2510,9 +2510,12 @@ rel_logical_value_exp(sql_query *query, if (symmetric) { sql_exp *tmp = NULL; - sql_subfunc *min = sql_bind_func(sql->sa, sql->session->schema, "sql_min", exp_subtype(re1), exp_subtype(re2), F_FUNC); - sql_subfunc *max = sql_bind_func(sql->sa, sql->session->schema, "sql_max", exp_subtype(re1), exp_subtype(re2), F_FUNC); - + sql_subfunc *min, *max; + + if (rel_convert_types(sql, rel ? *rel : NULL, rel ? *rel : NULL, &re1, &re2, 1, type_equal) < 0) + return NULL; + min = sql_bind_func(sql->sa, sql->session->schema, "sql_min", exp_subtype(re1), exp_subtype(re2), F_FUNC); + max = sql_bind_func(sql->sa, sql->session->schema, "sql_max", exp_subtype(re1), exp_subtype(re2), F_FUNC); if (!min || !max) return sql_error(sql, 02, SQLSTATE(42000) "min or max operator on types %s %s missing", exp_subtype(re1)->type->sqlname, exp_subtype(re2)->type->sqlname); tmp = exp_binop(sql->sa, re1, re2, min); @@ -2802,9 +2805,12 @@ rel_logical_exp(sql_query *query, sql_re /* for between 3 columns we use the between operator */ if (symmetric && (le->card == CARD_ATOM || (re1->card == CARD_ATOM && re2->card == CARD_ATOM))) { sql_exp *tmp = NULL; - sql_subfunc *min = sql_bind_func(sql->sa, sql->session->schema, "sql_min", exp_subtype(re1), exp_subtype(re2), F_FUNC); - sql_subfunc *max = sql_bind_func(sql->sa, sql->session->schema, "sql_max", exp_subtype(re1), exp_subtype(re2), F_FUNC); - + sql_subfunc *min, *max; + + if (rel_convert_types(sql, rel, rel, &re1, &re2, 1, type_equal) < 0) + return NULL; + min = sql_bind_func(sql->sa, sql->session->schema, "sql_min", exp_subtype(re1), exp_subtype(re2), F_FUNC); + max = sql_bind_func(sql->sa, sql->session->schema, "sql_max", exp_subtype(re1), exp_subtype(re2), F_FUNC); if (!min || !max) return sql_error(sql, 02, SQLSTATE(42000) "min or max operator on types %s %s missing", exp_subtype(re1)->type->sqlname, exp_subtype(re2)->type->sqlname); tmp = exp_binop(sql->sa, re1, re2, min); diff --git a/sql/test/SQLancer/Tests/sqlancer02.sql b/sql/test/SQLancer/Tests/sqlancer02.sql --- a/sql/test/SQLancer/Tests/sqlancer02.sql +++ b/sql/test/SQLancer/Tests/sqlancer02.sql @@ -23,6 +23,16 @@ SELECT t0.c0 FROM t0 WHERE ((((0.6540139 -- False ROLLBACK; +START TRANSACTION; +CREATE TABLE integers(i INTEGER); +INSERT INTO integers VALUES (1), (2), (3), (NULL); +select i between symmetric cast(1 as decimal) and cast(2 as double) from integers; + -- True + -- True + -- False + -- NULL +ROLLBACK; + START TRANSACTION; -- Bug 6910 CREATE TABLE t0("c0" DOUBLE NOT NULL); COPY 11 RECORDS INTO "sys"."t0" FROM stdin USING DELIMITERS E'\t',E'\n','"'; diff --git a/sql/test/SQLancer/Tests/sqlancer02.stable.out b/sql/test/SQLancer/Tests/sqlancer02.stable.out --- a/sql/test/SQLancer/Tests/sqlancer02.stable.out +++ b/sql/test/SQLancer/Tests/sqlancer02.stable.out @@ -44,6 +44,20 @@ stdout of test 'sqlancer02` in directory [ NULL ] [ false ] #ROLLBACK; +#START TRANSACTION; +#CREATE TABLE integers(i INTEGER); +#INSERT INTO integers VALUES (1), (2), (3), (NULL); +[ 4 ] +#select i between symmetric cast(1 as decimal) and cast(2 as double) from integers; +% sys.%3 # table_name +% %3 # name +% boolean # type +% 5 # length +[ true ] +[ true ] +[ false ] +[ NULL ] +#ROLLBACK; # 17:04:12 > # 17:04:12 > "Done." _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list