Changeset: 1a5795e15129 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1a5795e15129
Modified Files:
sql/server/rel_bin.c
sql/test/BugTracker-2012/Tests/All
sql/test/BugTracker-2012/Tests/hash_select.Bug-2947.sql
sql/test/BugTracker-2012/Tests/hash_select.Bug-2947.stable.err
sql/test/BugTracker-2012/Tests/hash_select.Bug-2947.stable.out
Branch: Dec2011
Log Message:
fixed bug 2947
properly handle hash based selection before the other
select expressions
diffs (236 lines):
diff --git a/sql/server/rel_bin.c b/sql/server/rel_bin.c
--- a/sql/server/rel_bin.c
+++ b/sql/server/rel_bin.c
@@ -1732,6 +1732,7 @@ rel2bin_predicate(mvc *sql)
static stmt *
rel2bin_hash_lookup( mvc *sql, sql_rel *rel, stmt *sub, sql_idx *i, node *en )
{
+ node *n;
sql_subtype *it = sql_bind_localtype("int");
sql_subtype *wrd = sql_bind_localtype("wrd");
stmt *h = NULL;
@@ -1740,8 +1741,8 @@ rel2bin_hash_lookup( mvc *sql, sql_rel *
sql_exp *l = e->l;
stmt *idx = bin_find_column(sql->sa, sub, l->l, sa_strconcat(sql->sa,
"%", i->base.name));
- /* TODO should be in key order! */
- for( en = rel->exps->h; en; en = en->next ) {
+ /* should be in key order! */
+ for( en = rel->exps->h, n = i->columns->h; en && n; en = en->next, n =
n->next ) {
sql_exp *e = en->data;
stmt *s = NULL;
@@ -1770,7 +1771,7 @@ rel2bin_select( mvc *sql, sql_rel *rel,
{
list *l;
node *en, *n;
- stmt *sub = NULL, *sel = NULL;
+ stmt *sub = NULL, *sel = NULL, *s = NULL;
stmt *predicate = NULL;
if (!rel->exps) {
@@ -1800,26 +1801,26 @@ rel2bin_select( mvc *sql, sql_rel *rel,
if ((p=find_prop(e->p, PROP_HASHIDX)) != NULL) {
sql_idx *i = p->value;
- sel = rel2bin_hash_lookup(sql, rel, sub, i, en);
+ s = rel2bin_hash_lookup(sql, rel, sub, i, en);
}
}
- if (!sel) {
- sel = stmt_relselect_init(sql->sa);
- for( en = rel->exps->h; en; en = en->next ) {
- /*stmt *s = exp_bin(sql, en->data, sub, NULL, NULL,
sel);*/
- stmt *s = exp_bin(sql, en->data, sub, NULL, NULL, NULL);
-
- if (!s) {
- assert(0);
- return NULL;
- }
- if (s->nrcols == 0){
- if (!predicate)
- predicate = rel2bin_predicate(sql);
- predicate = stmt_select(sql->sa, predicate, s,
cmp_equal);
- } else {
- stmt_relselect_fill(sel, s);
- }
+ sel = stmt_relselect_init(sql->sa);
+ if (s)
+ stmt_relselect_fill(sel, s);
+ for( en = rel->exps->h; en; en = en->next ) {
+ /*stmt *s = exp_bin(sql, en->data, sub, NULL, NULL, sel);*/
+ stmt *s = exp_bin(sql, en->data, sub, NULL, NULL, NULL);
+
+ if (!s) {
+ assert(0);
+ return NULL;
+ }
+ if (s->nrcols == 0){
+ if (!predicate)
+ predicate = rel2bin_predicate(sql);
+ predicate = stmt_select(sql->sa, predicate, s,
cmp_equal);
+ } else {
+ stmt_relselect_fill(sel, s);
}
}
diff --git a/sql/test/BugTracker-2012/Tests/All
b/sql/test/BugTracker-2012/Tests/All
--- a/sql/test/BugTracker-2012/Tests/All
+++ b/sql/test/BugTracker-2012/Tests/All
@@ -18,3 +18,4 @@ correlated_groupby_in_selection.Bug-3011
multicolumn_join.Bug-2998
simple_select.Bug-2988
interval_timestamp.Bug-3002
+hash_select.Bug-2947
diff --git a/sql/test/BugTracker-2012/Tests/hash_select.Bug-2947.sql
b/sql/test/BugTracker-2012/Tests/hash_select.Bug-2947.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2012/Tests/hash_select.Bug-2947.sql
@@ -0,0 +1,32 @@
+START TRANSACTION;
+SET SCHEMA "sys";
+CREATE TABLE "sys"."c__has_a" (
+ "owner_table" VARCHAR(32672),
+ "owner_id" BIGINT,
+ "relation_name" VARCHAR(32672),
+ "property_table" VARCHAR(32672),
+ "property_id" BIGINT,
+ "property_class" VARCHAR(32672)
+);
+CREATE INDEX "c__has_a_property_index" ON "sys"."c__has_a" ("property_table",
"property_id");
+COPY 1 RECORDS INTO "sys"."c__has_a" FROM stdin USING DELIMITERS '\t','\n','"';
+NULL NULL NULL "SIMPLE" 4 "simpleclass"
+COMMIT;
+
+select * from c__has_a where owner_table is null and property_table='SIMPLE'
and property_id = 4;
+
+DROP table c__has_a;
+
+
+
+CREATE TABLE FOO (
+ "a" VARCHAR(8),
+ "b" VARCHAR(8),
+ "c" BIGINT);
+CREATE INDEX FOO_INDEX ON FOO ("b","c");
+
+insert into foo (b,c)values('foo',3);
+
+select * from foo where a is null and b='foo' and c=3;
+
+DROP TABLE FOO;
diff --git a/sql/test/BugTracker-2012/Tests/hash_select.Bug-2947.stable.err
b/sql/test/BugTracker-2012/Tests/hash_select.Bug-2947.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2012/Tests/hash_select.Bug-2947.stable.err
@@ -0,0 +1,37 @@
+stderr of test 'hash_select.Bug-2947` in directory 'test/BugTracker-2012`
itself:
+
+
+# 21:58:29 >
+# 21:58:29 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"gdk_dbfarm=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB" "--set"
"mapi_open=true" "--set" "mapi_port=37666" "--set" "monet_prompt=" "--trace"
"--forcemito" "--set" "mal_listing=2" "--dbname=mTests_test_BugTracker-2012"
"--set" "mal_listing=0"
+# 21:58:29 >
+
+# builtin opt gdk_dbname = demo
+# builtin opt gdk_dbfarm =
/home/niels/scratch/rc-clean/Linux-x86_64/var/monetdb5/dbfarm
+# builtin opt gdk_debug = 0
+# builtin opt gdk_alloc_map = no
+# builtin opt gdk_vmtrim = yes
+# 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 gdk_dbfarm =
/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB
+# cmdline opt mapi_open = true
+# cmdline opt mapi_port = 37666
+# cmdline opt monet_prompt =
+# cmdline opt mal_listing = 2
+# cmdline opt gdk_dbname = mTests_test_BugTracker-2012
+# cmdline opt mal_listing = 0
+
+# 21:58:29 >
+# 21:58:29 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=niels"
"--port=37666"
+# 21:58:29 >
+
+
+# 21:58:29 >
+# 21:58:29 > "Done."
+# 21:58:29 >
+
diff --git a/sql/test/BugTracker-2012/Tests/hash_select.Bug-2947.stable.out
b/sql/test/BugTracker-2012/Tests/hash_select.Bug-2947.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2012/Tests/hash_select.Bug-2947.stable.out
@@ -0,0 +1,68 @@
+stdout of test 'hash_select.Bug-2947` in directory 'test/BugTracker-2012`
itself:
+
+
+# 21:58:29 >
+# 21:58:29 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"gdk_dbfarm=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB" "--set"
"mapi_open=true" "--set" "mapi_port=37666" "--set" "monet_prompt=" "--trace"
"--forcemito" "--set" "mal_listing=2" "--dbname=mTests_test_BugTracker-2012"
"--set" "mal_listing=0"
+# 21:58:29 >
+
+# MonetDB 5 server v11.7.8
+# This is an unreleased version
+# Serving database 'mTests_test_BugTracker-2012', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically
linked
+# Found 3.779 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2012 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on
mapi:monetdb://niels.nesco.mine.nu:37666/
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 21:58:29 >
+# 21:58:29 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=niels"
"--port=37666"
+# 21:58:29 >
+
+#START TRANSACTION;
+#CREATE TABLE "sys"."c__has_a" (
+# "owner_table" VARCHAR(32672),
+# "owner_id" BIGINT,
+# "relation_name" VARCHAR(32672),
+# "property_table" VARCHAR(32672),
+# "property_id" BIGINT,
+# "property_class" VARCHAR(32672)
+#);
+#CREATE INDEX "c__has_a_property_index" ON "sys"."c__has_a" ("property_table",
"property_id");
+#COPY 1 RECORDS INTO "sys"."c__has_a" FROM stdin USING DELIMITERS
'\t','\n','"';
+#NULL NULL NULL "SIMPLE" 4 "simpleclass"
+#COMMIT;
+[ 1 ]
+#COPY 1 RECORDS INTO "sys"."c__has_a" FROM stdin USING DELIMITERS
'\t','\n','"';
+#NULL NULL NULL "SIMPLE" 4 "simpleclass"
+#COMMIT;
+#select * from c__has_a where owner_table is null and property_table='SIMPLE'
and property_id = 4;
+% sys.c__has_a, sys.c__has_a, sys.c__has_a, sys.c__has_a,
sys.c__has_a, sys.c__has_a # table_name
+% owner_table, owner_id, relation_name, property_table, property_id,
property_class # name
+% varchar, bigint, varchar, varchar, bigint, varchar # type
+% 0, 1, 0, 6, 1, 11 # length
+[ NULL, NULL, NULL, "SIMPLE", 4, "simpleclass" ]
+#DROP table c__has_a;
+#CREATE TABLE FOO (
+# "a" VARCHAR(8),
+# "b" VARCHAR(8),
+# "c" BIGINT);
+#CREATE INDEX FOO_INDEX ON FOO ("b","c");
+#insert into foo (b,c)values('foo',3);
+[ 1 ]
+#select * from foo where a is null and b='foo' and c=3;
+% sys.foo, sys.foo, sys.foo # table_name
+% a, b, c # name
+% varchar, varchar, bigint # type
+% 0, 3, 1 # length
+[ NULL, "foo", 3 ]
+#DROP TABLE FOO;
+
+# 21:58:29 >
+# 21:58:29 > "Done."
+# 21:58:29 >
+
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list