Changeset: 35b25e60b302 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=35b25e60b302 Added Files: sql/test/BugTracker-2015/Tests/true_or_predicate.Bug-3733.sql sql/test/BugTracker-2015/Tests/true_or_predicate.Bug-3733.stable.err sql/test/BugTracker-2015/Tests/true_or_predicate.Bug-3733.stable.out Modified Files: sql/backends/monet5/rel_bin.c sql/test/BugTracker-2015/Tests/All Branch: default Log Message:
merged with oct2014 diffs (166 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 @@ -616,6 +616,18 @@ exp_bin(mvc *sql, sql_exp *e, stmt *left s = exp_bin(sql, n->data, left, right, grp, ext, cnt, sel1); if (!s) return s; + if (sel1 && sel1->nrcols == 0 && s->nrcols == 0) { + sql_subtype *bt = sql_bind_localtype("bit"); + sql_subfunc *f = sql_bind_func(sql->sa, sql->session->schema, "and", bt, bt, F_FUNC); + assert(f); + s = stmt_binop(sql->sa, sel1, s, f); + } + if (sel1 && sel1->nrcols && s->nrcols == 0) { + stmt *predicate = bin_first_column(sql->sa, left); + + predicate = stmt_const(sql->sa, predicate, stmt_bool(sql->sa, 1)); + s = stmt_uselect(sql->sa, predicate, s, cmp_equal, sel1); + } sel1 = s; } l = e->r; @@ -623,6 +635,18 @@ exp_bin(mvc *sql, sql_exp *e, stmt *left s = exp_bin(sql, n->data, left, right, grp, ext, cnt, sel2); if (!s) return s; + if (sel2 && sel2->nrcols == 0 && s->nrcols == 0) { + sql_subtype *bt = sql_bind_localtype("bit"); + sql_subfunc *f = sql_bind_func(sql->sa, sql->session->schema, "and", bt, bt, F_FUNC); + assert(f); + s = stmt_binop(sql->sa, sel2, s, f); + } + if (sel2 && sel2->nrcols && s->nrcols == 0) { + stmt *predicate = bin_first_column(sql->sa, left); + + predicate = stmt_const(sql->sa, predicate, stmt_bool(sql->sa, 1)); + s = stmt_uselect(sql->sa, predicate, s, cmp_equal, sel2); + } sel2 = s; } if (sel1->nrcols == 0 && sel2->nrcols == 0) { diff --git a/sql/test/BugTracker-2015/Tests/All b/sql/test/BugTracker-2015/Tests/All --- a/sql/test/BugTracker-2015/Tests/All +++ b/sql/test/BugTracker-2015/Tests/All @@ -33,3 +33,4 @@ adddrop_unknown_table.Bug-3718 schema_view.Bug-3708 outerjoin_project.Bug-3725 left_shift_inet.Bug-3730 +true_or_predicate.Bug-3733 diff --git a/sql/test/BugTracker-2015/Tests/true_or_predicate.Bug-3733.sql b/sql/test/BugTracker-2015/Tests/true_or_predicate.Bug-3733.sql new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2015/Tests/true_or_predicate.Bug-3733.sql @@ -0,0 +1,8 @@ +create table test (c1 int); +insert into test values(1); +SELECT * FROM test WHERE (true OR c1 = 3) AND c1 = 2; +SELECT * FROM test WHERE (true OR c1 = 3) AND c1 = 1; +SELECT * FROM test WHERE (false OR c1 = 3) AND c1 = 2; +SELECT * FROM test WHERE (false OR c1 = 3) AND c1 = 1; +drop table test; + diff --git a/sql/test/BugTracker-2015/Tests/true_or_predicate.Bug-3733.stable.err b/sql/test/BugTracker-2015/Tests/true_or_predicate.Bug-3733.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2015/Tests/true_or_predicate.Bug-3733.stable.err @@ -0,0 +1,37 @@ +stderr of test 'true_or_predicate.Bug-3733` in directory 'sql/test/BugTracker-2015` itself: + + +# 14:03:53 > +# 14:03:53 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=31324" "--set" "mapi_usock=/var/tmp/mtest-19512/.s.monetdb.31324" "--set" "monet_prompt=" "--forcemito" "--set" "mal_listing=2" "--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2015" "--set" "mal_listing=0" "--set" "embedded_r=yes" +# 14:03:53 > + +# builtin opt gdk_dbpath = /home/niels/scratch/rc-clean/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 = 31324 +# cmdline opt mapi_usock = /var/tmp/mtest-19512/.s.monetdb.31324 +# cmdline opt monet_prompt = +# cmdline opt mal_listing = 2 +# cmdline opt gdk_dbpath = /home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2015 +# cmdline opt mal_listing = 0 +# cmdline opt embedded_r = yes +# cmdline opt gdk_debug = 536870922 + +# 14:03:53 > +# 14:03:53 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-19512" "--port=31324" +# 14:03:53 > + + +# 14:03:53 > +# 14:03:53 > "Done." +# 14:03:53 > + diff --git a/sql/test/BugTracker-2015/Tests/true_or_predicate.Bug-3733.stable.out b/sql/test/BugTracker-2015/Tests/true_or_predicate.Bug-3733.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2015/Tests/true_or_predicate.Bug-3733.stable.out @@ -0,0 +1,57 @@ +stdout of test 'true_or_predicate.Bug-3733` in directory 'sql/test/BugTracker-2015` itself: + + +# 14:03:53 > +# 14:03:53 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=31324" "--set" "mapi_usock=/var/tmp/mtest-19512/.s.monetdb.31324" "--set" "monet_prompt=" "--forcemito" "--set" "mal_listing=2" "--dbpath=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB/mTests_sql_test_BugTracker-2015" "--set" "mal_listing=0" "--set" "embedded_r=yes" +# 14:03:53 > + +# MonetDB 5 server v11.19.12 +# This is an unreleased version +# Serving database 'mTests_sql_test_BugTracker-2015', using 4 threads +# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically linked +# Found 7.333 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:31324/ +# Listening for UNIX domain connection requests on mapi:monetdb:///var/tmp/mtest-19512/.s.monetdb.31324 +# MonetDB/GIS module loaded +# MonetDB/SQL module loaded +# MonetDB/R module loaded + +Ready. + +# 14:03:53 > +# 14:03:53 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=/var/tmp/mtest-19512" "--port=31324" +# 14:03:53 > + +#create table test (c1 int); +#insert into test values(1); +[ 1 ] +#SELECT * FROM test WHERE (true OR c1 = 3) AND c1 = 2; +% sys.test # table_name +% c1 # name +% int # type +% 1 # length +#SELECT * FROM test WHERE (true OR c1 = 3) AND c1 = 1; +% sys.test # table_name +% c1 # name +% int # type +% 1 # length +[ 1 ] +#SELECT * FROM test WHERE (false OR c1 = 3) AND c1 = 2; +% sys.test # table_name +% c1 # name +% int # type +% 1 # length +#SELECT * FROM test WHERE (false OR c1 = 3) AND c1 = 1; +% sys.test # table_name +% c1 # name +% int # type +% 1 # length +#drop table test; + +# 14:03:53 > +# 14:03:53 > "Done." +# 14:03:53 > + _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list