Changeset: d414fb156e84 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d414fb156e84 Added Files: sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.sql sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.stable.err sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.stable.out Modified Files: sql/common/sql_types.h sql/server/rel_select.c sql/test/BugTracker-2016/Tests/All Branch: Jul2015 Log Message:
fixes for bug 3900, ie handle null (type any) in in/between expressions diffs (182 lines): diff --git a/sql/common/sql_types.h b/sql/common/sql_types.h --- a/sql/common/sql_types.h +++ b/sql/common/sql_types.h @@ -18,6 +18,7 @@ #define EC_MAX 16 #define EC_ANY 0 +#define IS_ANY(e) (e==EC_ANY) #define EC_TABLE 1 #define EC_BIT 2 #define EC_CHAR 3 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 @@ -2852,7 +2852,12 @@ rel_logical_value_exp(mvc *sql, sql_rel sql_rel *z = NULL, *rl; r = rel_value_exp(sql, &z, sval, f, ek); - if (!r || !(r=rel_check_type(sql, st, r, type_equal))) { + if (l && IS_ANY(st->type->eclass)){ + l = rel_check_type(sql, exp_subtype(r), l, type_equal); + if (l) + st = exp_subtype(l); + } + if (!l || !r || !(r=rel_check_type(sql, st, r, type_equal))) { rel_destroy(right); return NULL; } @@ -3790,7 +3795,35 @@ rel_binop_(mvc *sql, sql_exp *l, sql_exp r = exp_aggr1(sql->sa, r, zero_or_one, 0, 0, CARD_ATOM, 0); } - return exp_binop(sql->sa, l, r, f); + /* bind types of l and r */ + t1 = exp_subtype(l); + t2 = exp_subtype(r); + if (IS_ANY(t1->type->eclass) || IS_ANY(t2->type->eclass)) { + sql_exp *ol = l; + sql_exp *or = r; + + if (IS_ANY(t1->type->eclass) && IS_ANY(t2->type->eclass)) { + sql_subtype *s = sql_bind_localtype("str"); + l = rel_check_type(sql, s, l, type_equal); + r = rel_check_type(sql, s, r, type_equal); + } else if (IS_ANY(t1->type->eclass)) { + l = rel_check_type(sql, t2, l, type_equal); + } else { + r = rel_check_type(sql, t1, r, type_equal); + } + if (l && r) + return exp_binop(sql->sa, l, r, f); + + /* reset error */ + sql->session->status = 0; + sql->errstr[0] = '\0'; + f = NULL; + + l = ol; + r = or; + } + if (f) + return exp_binop(sql->sa, l, r, f); } else { sql_exp *ol = l; sql_exp *or = r; diff --git a/sql/test/BugTracker-2016/Tests/All b/sql/test/BugTracker-2016/Tests/All --- a/sql/test/BugTracker-2016/Tests/All +++ b/sql/test/BugTracker-2016/Tests/All @@ -7,3 +7,4 @@ case-with-string-Bug.3932 date_calculation_and_comparison_wrong_results.Bug-3940 wrong-nonil-property-with-copy-binary-into.Bug-3937-prepare wrong-nonil-property-with-copy-binary-into.Bug-3937 +null_in_null.Bug-3900 diff --git a/sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.sql b/sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.sql new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.sql @@ -0,0 +1,3 @@ +select null in (null); +select null in (1); +select null between null and null; diff --git a/sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.stable.err b/sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.stable.err @@ -0,0 +1,37 @@ +stderr of test 'null_in_null.Bug-3900` in directory 'sql/test/BugTracker-2016` itself: + + +# 21:33:36 > +# 21:33:36 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=31993" "--set" "mapi_usock=/var/tmp/mtest-11290/.s.monetdb.31993" "--set" "monet_prompt=" "--forcemito" "--set" "mal_listing=2" "--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2016" "--set" "mal_listing=0" "--set" "embedded_r=yes" +# 21:33:36 > + +# builtin opt gdk_dbpath = /home/niels/scratch/rc-monetdb/Linux-x86_64/var/monetdb5/dbfarm/demo +# builtin opt gdk_debug = 0 +# builtin opt gdk_vmtrim = no +# builtin opt monet_prompt = > +# builtin opt monet_daemon = no +# builtin opt mapi_port = 50000 +# builtin opt mapi_open = false +# builtin opt mapi_autosense = false +# builtin opt sql_optimizer = default_pipe +# builtin opt sql_debug = 0 +# cmdline opt gdk_nr_threads = 0 +# cmdline opt mapi_open = true +# cmdline opt mapi_port = 31993 +# cmdline opt mapi_usock = /var/tmp/mtest-11290/.s.monetdb.31993 +# cmdline opt monet_prompt = +# cmdline opt mal_listing = 2 +# cmdline opt gdk_dbpath = /home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2016 +# cmdline opt mal_listing = 0 +# cmdline opt embedded_r = yes +# cmdline opt gdk_debug = 536870922 + +# 21:33:36 > +# 21:33:36 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-11290" "--port=31993" +# 21:33:36 > + + +# 21:33:36 > +# 21:33:36 > "Done." +# 21:33:36 > + diff --git a/sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.stable.out b/sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.stable.out @@ -0,0 +1,54 @@ +stdout of test 'null_in_null.Bug-3900` in directory 'sql/test/BugTracker-2016` itself: + + +# 21:33:36 > +# 21:33:36 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=31993" "--set" "mapi_usock=/var/tmp/mtest-11290/.s.monetdb.31993" "--set" "monet_prompt=" "--forcemito" "--set" "mal_listing=2" "--dbpath=/home/niels/scratch/rc-monetdb/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2016" "--set" "mal_listing=0" "--set" "embedded_r=yes" +# 21:33:36 > + +# MonetDB 5 server v11.21.12 +# This is an unreleased version +# Serving database 'mTests_sql_test_BugTracker-2016', using 4 threads +# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs and 128bit integers dynamically linked +# Found 7.332 GiB available main-memory. +# Copyright (c) 1993-July 2008 CWI. +# Copyright (c) August 2008-2015 MonetDB B.V., all rights reserved +# Visit http://www.monetdb.org/ for further information +# Listening for connection requests on mapi:monetdb://localhost.nes.nl:31993/ +# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-11290/.s.monetdb.31993 +# MonetDB/GIS module loaded +# Start processing logs sql/sql_logs version 52200 +# Start reading the write-ahead log 'sql_logs/sql/log.8' +# Finished reading the write-ahead log 'sql_logs/sql/log.8' +# Finished processing logs sql/sql_logs +# MonetDB/SQL module loaded +# MonetDB/R module loaded + +Ready. + +# 21:33:36 > +# 21:33:36 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-11290" "--port=31993" +# 21:33:36 > + +#select null in (null); +% .L1 # table_name +% =_single_value # name +% boolean # type +% 5 # length +[ NULL ] +#select null in (1); +% .L1 # table_name +% =_single_value # name +% boolean # type +% 5 # length +[ NULL ] +#select null between null and null; +% .L # table_name +% and_>=_single_value # name +% boolean # type +% 5 # length +[ NULL ] + +# 21:33:36 > +# 21:33:36 > "Done." +# 21:33:36 > + _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list