Changeset: f926113c24fe for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f926113c24fe
Added Files:
sql/test/mergetables/Tests/mergetable_rel_push_aggr_down.sql
sql/test/mergetables/Tests/mergetable_rel_push_aggr_down.stable.err
sql/test/mergetables/Tests/mergetable_rel_push_aggr_down.stable.out
Modified Files:
gdk/gdk_cand.c
sql/backends/monet5/sql_cat.c
sql/server/rel_optimizer.c
sql/test/merge-partitions/Tests/mergepart01.stable.err
sql/test/merge-partitions/Tests/mergepart01.stable.out
sql/test/merge-partitions/Tests/mergepart05.stable.err
sql/test/merge-partitions/Tests/mergepart07.stable.err
sql/test/merge-partitions/Tests/mergepart18.stable.err
sql/test/merge-partitions/Tests/mergepart19.stable.err
sql/test/mergetables/Tests/All
sql/test/mergetables/Tests/addtable.stable.err
sql/test/mergetables/Tests/doubletable.stable.err
sql/test/subquery/Tests/subquery3.sql
sql/test/subquery/Tests/subquery3.stable.err
sql/test/subquery/Tests/subquery3.stable.out
Branch: default
Log Message:
Merged with linear-hashing
diffs (truncated from 609 to 300 lines):
diff --git a/gdk/gdk_cand.c b/gdk/gdk_cand.c
--- a/gdk/gdk_cand.c
+++ b/gdk/gdk_cand.c
@@ -393,11 +393,6 @@ canditer_init(struct canditer *ci, BAT *
ci->oids = (const oid *) s->theap.base;
ci->seq = ci->oids[0];
ci->noids = cnt;
- if (ci->oids[ci->noids - 1] - ci->oids[0] == ci->noids - 1) {
- /* actually dense */
- ci->tpe = cand_dense;
- ci->oids = NULL;
- }
} else {
/* materialized dense: no exceptions */
ci->tpe = cand_dense;
@@ -405,47 +400,34 @@ canditer_init(struct canditer *ci, BAT *
switch (ci->tpe) {
case cand_materialized:
if (b != NULL) {
- if (ci->oids[ci->noids - 1] < b->hseqbase) {
+ BUN p = binsearchcand(ci->oids, cnt - 1, b->hseqbase);
+ /* p == cnt means candidate list is completely
+ * before b */
+ ci->offset = p;
+ ci->oids += p;
+ cnt -= p;
+ if (cnt > 0) {
+ cnt = binsearchcand(ci->oids, cnt - 1,
+ b->hseqbase + BATcount(b));
+ /* cnt == 0 means candidate list is
+ * completely after b */
+ }
+ if (cnt == 0) {
+ /* no overlap */
*ci = (struct canditer) {
.tpe = cand_dense,
.s = s,
};
return 0;
}
- if (ci->oids[0] < b->hseqbase) {
- BUN lo = 0;
- BUN hi = cnt - 1;
- const oid o = b->hseqbase;
- /* loop invariant:
- * ci->oids[lo] < o <= ci->oids[hi] */
- while (hi - lo > 1) {
- BUN mid = (lo + hi) / 2;
- if (ci->oids[mid] >= o)
- hi = mid;
- else
- lo = mid;
- }
- ci->offset = hi;
- cnt -= hi;
- ci->oids += hi;
- ci->seq = ci->oids[0];
+ ci->seq = ci->oids[0];
+ ci->noids = cnt;
+ if (ci->oids[cnt - 1] - ci->seq == cnt - 1) {
+ /* actually dense */
+ ci->tpe = cand_dense;
+ ci->oids = NULL;
+ ci->noids = 0;
}
- if (ci->oids[cnt - 1] >= b->hseqbase + BATcount(b)) {
- BUN lo = 0;
- BUN hi = cnt - 1;
- const oid o = b->hseqbase + BATcount(b);
- /* loop invariant:
- * ci->oids[lo] < o <= ci->oids[hi] */
- while (hi - lo > 1) {
- BUN mid = (lo + hi) / 2;
- if (ci->oids[mid] >= o)
- hi = mid;
- else
- lo = mid;
- }
- cnt = hi;
- }
- ci->noids = cnt;
}
break;
case cand_except:
diff --git a/sql/backends/monet5/sql_cat.c b/sql/backends/monet5/sql_cat.c
--- a/sql/backends/monet5/sql_cat.c
+++ b/sql/backends/monet5/sql_cat.c
@@ -149,7 +149,7 @@ validate_alter_table_add_table(mvc *sql,
*mt = rmt;
*pt = rpt;
if (!update && rmt && (!isMergeTable(rmt) && !isReplicaTable(rmt)))
- throw(SQL,call,SQLSTATE(42S02) "ALTER TABLE: cannot add table
'%s.%s' to table '%s.%s'", psname, ptname, msname, mtname);
+ throw(SQL,call,SQLSTATE(42S02) "ALTER TABLE: cannot add table
'%s.%s' to %s '%s.%s'", psname, ptname, TABLE_TYPE_DESCRIPTION(rmt->type,
rmt->properties), msname, mtname);
if (rmt && rpt) {
char *msg;
node *n = cs_find_id(&rmt->members, rpt->base.id);
@@ -160,9 +160,9 @@ validate_alter_table_add_table(mvc *sql,
if (ms->base.id != ps->base.id)
throw(SQL,call,SQLSTATE(42000) "ALTER TABLE: all
children tables of '%s.%s' must be part of schema '%s'", msname, mtname,
msname);
if (n && !update)
- throw(SQL,call,SQLSTATE(42S02) "ALTER TABLE: table
'%s.%s' is already part of the %s '%s.%s'", psname, ptname, errtable, msname,
mtname);
+ throw(SQL,call,SQLSTATE(42S02) "ALTER TABLE: table
'%s.%s' is already part of %s '%s.%s'", psname, ptname, errtable, msname,
mtname);
if (!n && update)
- throw(SQL,call,SQLSTATE(42S02) "ALTER TABLE: table
'%s.%s' isn't part of the %s '%s.%s'", psname, ptname, errtable, msname,
mtname);
+ throw(SQL,call,SQLSTATE(42S02) "ALTER TABLE: table
'%s.%s' isn't part of %s '%s.%s'", psname, ptname, errtable, msname, mtname);
if ((msg = rel_check_tables(rmt, rpt, errtable)) != NULL)
return msg;
return MAL_SUCCEED;
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -4200,7 +4200,7 @@ rel_push_aggr_down(int *changes, mvc *sq
ne = exp_uses_exp( rel->exps, e);
if (!ne)
- ne = e;
+ continue;
ne = list_find_exp( u->exps, ne);
assert(ne);
ne = exp_ref(sql->sa, ne);
diff --git a/sql/test/merge-partitions/Tests/mergepart01.stable.err
b/sql/test/merge-partitions/Tests/mergepart01.stable.err
--- a/sql/test/merge-partitions/Tests/mergepart01.stable.err
+++ b/sql/test/merge-partitions/Tests/mergepart01.stable.err
@@ -31,7 +31,7 @@ stderr of test 'mergepart01` in director
MAPI = (monetdb) /var/tmp/mtest-13251/.s.monetdb.37915
QUERY = ALTER TABLE testme ADD TABLE subtable1 AS PARTITION FROM 5 TO 10;
--error
-ERROR = !ALTER TABLE: table 'sys.subtable1' is already part of the RANGE
PARTITION TABLE 'sys.testme'
+ERROR = !ALTER TABLE: table 'sys.subtable1' is already part of RANGE PARTITION
TABLE 'sys.testme'
CODE = 42S02
MAPI = (monetdb) /var/tmp/mtest-13251/.s.monetdb.37915
QUERY = ALTER TABLE testme ADD TABLE wrongtable AS PARTITION FROM 5 TO 6;
--error
diff --git a/sql/test/merge-partitions/Tests/mergepart05.stable.err
b/sql/test/merge-partitions/Tests/mergepart05.stable.err
--- a/sql/test/merge-partitions/Tests/mergepart05.stable.err
+++ b/sql/test/merge-partitions/Tests/mergepart05.stable.err
@@ -31,15 +31,15 @@ stderr of test 'mergepart05` in director
MAPI = (monetdb) /var/tmp/mtest-1799/.s.monetdb.30832
QUERY = ALTER TABLE listparts ADD TABLE subtable1 AS PARTITION FROM 'else' TO
RANGE MAXVALUE; --error
-ERROR = !ALTER TABLE: table 'sys.subtable1' is already part of the RANGE
PARTITION TABLE 'sys.listparts'
+ERROR = !ALTER TABLE: table 'sys.subtable1' is already part of RANGE PARTITION
TABLE 'sys.listparts'
CODE = 42S02
MAPI = (monetdb) /var/tmp/mtest-1799/.s.monetdb.30832
QUERY = ALTER TABLE listparts ADD TABLE subtable1 AS PARTITION FROM RANGE
MINVALUE TO RANGE MAXVALUE; --error
-ERROR = !ALTER TABLE: table 'sys.subtable1' is already part of the RANGE
PARTITION TABLE 'sys.listparts'
+ERROR = !ALTER TABLE: table 'sys.subtable1' is already part of RANGE PARTITION
TABLE 'sys.listparts'
CODE = 42S02
MAPI = (monetdb) /var/tmp/mtest-1799/.s.monetdb.30832
QUERY = ALTER TABLE listparts ADD TABLE subtable1 AS PARTITION FROM 'hello' TO
'world';
-ERROR = !ALTER TABLE: table 'sys.subtable1' is already part of the RANGE
PARTITION TABLE 'sys.listparts'
+ERROR = !ALTER TABLE: table 'sys.subtable1' is already part of RANGE PARTITION
TABLE 'sys.listparts'
CODE = 42S02
MAPI = (monetdb) /var/tmp/mtest-1799/.s.monetdb.30832
QUERY = ALTER TABLE listparts ADD TABLE subtable1 AS PARTITION FROM 'hello"'
TO '"world'; --error
diff --git a/sql/test/merge-partitions/Tests/mergepart07.stable.err
b/sql/test/merge-partitions/Tests/mergepart07.stable.err
--- a/sql/test/merge-partitions/Tests/mergepart07.stable.err
+++ b/sql/test/merge-partitions/Tests/mergepart07.stable.err
@@ -65,7 +65,7 @@ ERROR = !ALTER TABLE: range bound cannot
CODE = 42000
MAPI = (monetdb) /var/tmp/mtest-15212/.s.monetdb.36187
QUERY = ALTER TABLE anothertest ADD TABLE othersub1 AS PARTITION FROM 'nono'
TO 'wrong' WITH NULL VALUES; --error
-ERROR = !ALTER TABLE: table 'sys.othersub1' is already part of the RANGE
PARTITION TABLE 'sys.anothertest'
+ERROR = !ALTER TABLE: table 'sys.othersub1' is already part of RANGE PARTITION
TABLE 'sys.anothertest'
CODE = 42S02
MAPI = (monetdb) /var/tmp/mtest-13251/.s.monetdb.37915
QUERY = ALTER TABLE anothertest ADD TABLE othersub1 AS PARTITION FROM 'a' TO
'string'; --error
diff --git a/sql/test/merge-partitions/Tests/mergepart18.stable.err
b/sql/test/merge-partitions/Tests/mergepart18.stable.err
--- a/sql/test/merge-partitions/Tests/mergepart18.stable.err
+++ b/sql/test/merge-partitions/Tests/mergepart18.stable.err
@@ -30,7 +30,7 @@ stderr of test 'mergepart18` in director
MAPI = (monetdb) /var/tmp/mtest-13251/.s.monetdb.37915
QUERY = ALTER TABLE updateme SET TABLE subt1 AS PARTITION FROM '1' TO '100';
--error
-ERROR = !ALTER TABLE: table 'sys.subt1' isn't part of the RANGE PARTITION
TABLE 'sys.updateme'
+ERROR = !ALTER TABLE: table 'sys.subt1' isn't part of RANGE PARTITION TABLE
'sys.updateme'
CODE = 42S02
MAPI = (monetdb) /var/tmp/mtest-13251/.s.monetdb.37915
QUERY = ALTER TABLE updateme SET TABLE subt1 AS PARTITION FROM '-100' TO '0';
--error
diff --git a/sql/test/merge-partitions/Tests/mergepart19.stable.err
b/sql/test/merge-partitions/Tests/mergepart19.stable.err
--- a/sql/test/merge-partitions/Tests/mergepart19.stable.err
+++ b/sql/test/merge-partitions/Tests/mergepart19.stable.err
@@ -30,7 +30,7 @@ stderr of test 'mergepart19` in director
MAPI = (monetdb) /var/tmp/mtest-15034/.s.monetdb.31422
QUERY = ALTER TABLE testme SET TABLE subt1 AS PARTITION IN ('21', '22', '23');
--error
-ERROR = !ALTER TABLE: table 'sys.subt1' isn't part of the LIST PARTITION TABLE
'sys.testme'
+ERROR = !ALTER TABLE: table 'sys.subt1' isn't part of LIST PARTITION TABLE
'sys.testme'
CODE = 42S02
MAPI = (monetdb) /var/tmp/mtest-15034/.s.monetdb.31422
QUERY = ALTER TABLE testme SET TABLE subt1 AS PARTITION IN ('44', '45', '46');
--error
diff --git a/sql/test/mergetables/Tests/All b/sql/test/mergetables/Tests/All
--- a/sql/test/mergetables/Tests/All
+++ b/sql/test/mergetables/Tests/All
@@ -32,3 +32,4 @@ sqlsmith.Bug-6480
sqlsmith-exists
sqlsmith-exists2
mergedb_drop
+mergetable_rel_push_aggr_down
diff --git a/sql/test/mergetables/Tests/addtable.stable.err
b/sql/test/mergetables/Tests/addtable.stable.err
--- a/sql/test/mergetables/Tests/addtable.stable.err
+++ b/sql/test/mergetables/Tests/addtable.stable.err
@@ -29,7 +29,7 @@ stderr of test 'addtable` in directory '
MAPI = (monetdb) /var/tmp/mtest-19670/.s.monetdb.38251
QUERY = alter table tmp1 add table tmp2;
-ERROR = !ALTER TABLE: cannot add table 'sys.tmp2' to table 'sys.tmp1'
+ERROR = !ALTER TABLE: cannot add table 'sys.tmp2' to TABLE 'sys.tmp1'
CODE = 42S02
# 13:47:16 >
diff --git a/sql/test/mergetables/Tests/doubletable.stable.err
b/sql/test/mergetables/Tests/doubletable.stable.err
--- a/sql/test/mergetables/Tests/doubletable.stable.err
+++ b/sql/test/mergetables/Tests/doubletable.stable.err
@@ -32,11 +32,11 @@ stderr of test 'doubletable` in director
MAPI = (monetdb) /var/tmp/mtest-30244/.s.monetdb.33503
QUERY = ALTER TABLE complete ADD TABLE part1;
-ERROR = !ALTER TABLE: table 'sys.part1' is already part of the MERGE TABLE
'sys.complete'
+ERROR = !ALTER TABLE: table 'sys.part1' is already part of MERGE TABLE
'sys.complete'
CODE = 42S02
MAPI = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685
QUERY = ALTER TABLE complete ADD TABLE part2;
-ERROR = !ALTER TABLE: table 'sys.part2' is already part of the MERGE TABLE
'sys.complete'
+ERROR = !ALTER TABLE: table 'sys.part2' is already part of MERGE TABLE
'sys.complete'
CODE = 42S02
diff --git a/sql/test/mergetables/Tests/mergetable_rel_push_aggr_down.sql
b/sql/test/mergetables/Tests/mergetable_rel_push_aggr_down.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/mergetables/Tests/mergetable_rel_push_aggr_down.sql
@@ -0,0 +1,57 @@
+start transaction;
+
+CREATE SCHEMA "myschema";
+
+CREATE MERGE TABLE "myschema"."mymerge" (
+"col1" CHARACTER LARGE OBJECT,
+"col2" CHARACTER LARGE OBJECT,
+"col3" CHARACTER LARGE OBJECT,
+"col4" CHARACTER LARGE OBJECT,
+"col5" CHARACTER LARGE OBJECT,
+"col6" BIGINT,
+"col7" BIGINT
+);
+
+CREATE TABLE "myschema"."subt1" (
+"col1" CHARACTER LARGE OBJECT,
+"col2" CHARACTER LARGE OBJECT,
+"col3" CHARACTER LARGE OBJECT,
+"col4" CHARACTER LARGE OBJECT,
+"col5" CHARACTER LARGE OBJECT,
+"col6" BIGINT,
+"col7" BIGINT
+);
+
+CREATE TABLE "myschema"."subt2" (
+"col1" CHARACTER LARGE OBJECT,
+"col2" CHARACTER LARGE OBJECT,
+"col3" CHARACTER LARGE OBJECT,
+"col4" CHARACTER LARGE OBJECT,
+"col5" CHARACTER LARGE OBJECT,
+"col6" BIGINT,
+"col7" BIGINT
+);
+
+alter table "myschema"."mymerge" add table "myschema"."subt1";
+alter table "myschema"."mymerge" add table "myschema"."subt2";
+
+select count(*) FROM (
+ SELECT myalias.col5 AS field1,
+ myalias.col4 AS field2,
+ myalias.col3 AS field3,
+ myalias.col1 AS field4,
+ myalias.col2 AS field5,
+ (COUNT(*)),
+ 'bb7fd938-43b0-11ea-b44c-845ddc3cb4be' AS MyID
+ FROM "myschema"."mymerge" myalias
+ WHERE myalias.col7 >= 1577914380 AND myalias.col7 <= 1580423692
+ GROUP BY field3, field5, field1, field4, field2) AS mycount;
+
+select count(*) FROM (
+ SELECT myalias.col5 AS field1,
+ myalias.col4 AS field2,
+ (COUNT(*))
+ FROM "myschema"."mymerge" myalias
+ GROUP BY field1, field2) AS mycount;
+
+rollback;
diff --git
a/sql/test/mergetables/Tests/mergetable_rel_push_aggr_down.stable.err
b/sql/test/mergetables/Tests/mergetable_rel_push_aggr_down.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/mergetables/Tests/mergetable_rel_push_aggr_down.stable.err
@@ -0,0 +1,30 @@
+stderr of test 'mergetable_rel_push_aggr_down` in directory
'sql/test/mergetables` itself:
+
+
+# 12:55:05 >
+# 12:55:05 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=39679" "--set"
"mapi_usock=/var/tmp/mtest-61455/.s.monetdb.39679" "--forcemito"
"--dbpath=/home/ferreira/repositories/MonetDB-Nov2019/BUILD/var/MonetDB/mTests_sql_test_mergetables"
"--set" "embedded_c=true"
+# 12:55:05 >
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list