Changeset: 5cffb522e25e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5cffb522e25e Modified Files: sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_subquery.c sql/test/subquery/Tests/subquery4.sql sql/test/subquery/Tests/subquery4.stable.out Branch: pushdown Log Message:
merged with default diffs (152 lines): diff --git a/sql/backends/monet5/sql_subquery.c b/sql/backends/monet5/sql_subquery.c --- a/sql/backends/monet5/sql_subquery.c +++ b/sql/backends/monet5/sql_subquery.c @@ -854,7 +854,7 @@ SQLsubexist(bat *ret, const bat *bp, con { BAT *b, *g, *e, *res; bit T = TRUE; - BUN offset = 0; + //BUN offset = 0; (void)no_nil; if ((b = BATdescriptor(*bp)) == NULL) { @@ -876,6 +876,7 @@ SQLsubexist(bat *ret, const bat *bp, con throw(SQL, "aggr.subexist", SQLSTATE(HY013) MAL_MALLOC_FAIL); } BAThseqbase(res, e->hseqbase); +#if 0 offset = g->hseqbase - b->hseqbase; if (BATcount(g) > 0) { BUN q, o, s; @@ -900,6 +901,7 @@ SQLsubexist(bat *ret, const bat *bp, con } } } +#endif res->hseqbase = g->hseqbase; res->tnil = 0; res->tnonil = 1; @@ -948,8 +950,8 @@ str SQLsubnot_exist(bat *ret, const bat *bp, const bat *gp, const bat *gpe, bit *no_nil) { BAT *b, *g, *e, *res; - bit F = FALSE, hasnil = 0; - BUN offset = 0; + bit F = FALSE; + //BUN offset = 0; (void)no_nil; if ((b = BATdescriptor(*bp)) == NULL) { @@ -971,6 +973,7 @@ SQLsubnot_exist(bat *ret, const bat *bp, throw(SQL, "aggr.subnot_exist", SQLSTATE(HY013) MAL_MALLOC_FAIL); } BAThseqbase(res, e->hseqbase); +#if 0 offset = g->hseqbase - b->hseqbase; if (BATcount(g) > 0) { BUN q, o, s; @@ -988,17 +991,17 @@ SQLsubnot_exist(bat *ret, const bat *bp, const void *bv = BUNtail(bi, q); oid id = *(oid*)BUNtail(gi, s); - if (ret[id] != TRUE) { + if (ret[id] == FALSE) { if (ocmp(bv, nilp) == 0) { - ret[id] = bit_nil; - hasnil = 1; + ret[id] = TRUE; } } } } +#endif res->hseqbase = g->hseqbase; - res->tnil = hasnil != 0; - res->tnonil = hasnil == 0; + res->tnil = 0; + res->tnonil = 1; res->tsorted = res->trevsorted = 0; res->tkey = 0; BBPunfix(b->batCacheid); diff --git a/sql/test/subquery/Tests/subquery4.sql b/sql/test/subquery/Tests/subquery4.sql --- a/sql/test/subquery/Tests/subquery4.sql +++ b/sql/test/subquery/Tests/subquery4.sql @@ -148,6 +148,33 @@ SELECT i1.i, i2.i FROM integers i1, inte SELECT DISTINCT CAST((SELECT SUM(i2.i + i1.i)) AS BIGINT) FROM integers i1, integers i2; +SELECT NOT EXISTS(SELECT i1.i) from integers i1; + -- False + -- False + -- False + -- False + +SELECT i1.i, i2.i FROM integers i1 INNER JOIN integers i2 ON EXISTS (SELECT i1.i) = NOT EXISTS (SELECT i2.i); + -- empty + +SELECT i1.i, i2.i FROM integers i1 INNER JOIN integers i2 ON EXISTS (SELECT i1.i) = EXISTS (SELECT i2.i); + -- 1 1 + -- 1 2 + -- 1 3 + -- 1 NULL + -- 2 1 + -- 2 2 + -- 2 3 + -- 2 NULL + -- 3 1 + -- 3 2 + -- 3 3 + -- 3 NULL + -- NULL 1 + -- NULL 2 + -- NULL 3 + -- NULL NULL + UPDATE another_T SET col1 = MIN(col1); --error, aggregates not allowed in update set clause UPDATE another_T SET col2 = 1 WHERE col1 = SUM(col2); --error, aggregates not allowed in update set clause UPDATE another_T SET col3 = (SELECT MAX(col5)); --error, aggregates not allowed in update set clause diff --git a/sql/test/subquery/Tests/subquery4.stable.out b/sql/test/subquery/Tests/subquery4.stable.out --- a/sql/test/subquery/Tests/subquery4.stable.out +++ b/sql/test/subquery/Tests/subquery4.stable.out @@ -248,6 +248,41 @@ stdout of test 'subquery4` in directory [ NULL ] [ 5 ] [ 6 ] +#SELECT NOT EXISTS(SELECT i1.i) from integers i1; +% . # table_name +% %15 # name +% boolean # type +% 5 # length +[ false ] +[ false ] +[ false ] +[ false ] +#SELECT i1.i, i2.i FROM integers i1 INNER JOIN integers i2 ON EXISTS (SELECT i1.i) = NOT EXISTS (SELECT i2.i); +% .i1, .i2 # table_name +% i, i # name +% int, int # type +% 1, 1 # length +#SELECT i1.i, i2.i FROM integers i1 INNER JOIN integers i2 ON EXISTS (SELECT i1.i) = EXISTS (SELECT i2.i); +% .i1, .i2 # table_name +% i, i # name +% int, int # type +% 1, 1 # length +[ 1, 1 ] +[ 1, 2 ] +[ 1, 3 ] +[ 1, NULL ] +[ 2, 1 ] +[ 2, 2 ] +[ 2, 3 ] +[ 2, NULL ] +[ 3, 1 ] +[ 3, 2 ] +[ 3, 3 ] +[ 3, NULL ] +[ NULL, 1 ] +[ NULL, 2 ] +[ NULL, 3 ] +[ NULL, NULL ] #UPDATE another_T SET col4 = (SELECT SUM(col4 + ColID) FROM tbl_ProductSales); --4 rows affected [ 4 ] #SELECT col4 FROM another_T; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list