Changeset: 8319738e8d1f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8319738e8d1f
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
sql/backends/monet5/sql.c
sql/backends/monet5/sql.h
sql/backends/monet5/sql.mal
sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out
sql/test/BugTracker-2016/Tests/memory-consumption-query-PLAN-25joins.Bug-3972.stable.out
Branch: Nov2019
Log Message:
moved grouped zero_or_one into c. Solves problems with mergetable/mitosis
diffs (162 lines):
diff --git a/clients/Tests/MAL-signatures.stable.out
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -11772,7 +11772,7 @@ stdout of test 'MAL-signatures` in direc
[ "sql", "subdelta", "command sql.subdelta(col:bat[:oid],
cand:bat[:oid], uid:bat[:oid], uval:bat[:oid]):bat[:oid] ",
"DELTAsub2;", "Return a single bat of selected delta." ]
[ "sql", "subdelta", "command sql.subdelta(col:bat[:oid],
cand:bat[:oid], uid:bat[:oid], uval:bat[:oid], ins:bat[:oid]):bat[:oid] ",
"DELTAsub;", "Return a single bat of selected delta." ]
[ "sql", "subnull", "command sql.subnull(l:bat[:any_1],
gp:bat[:oid], gpe:bat[:oid], no_nil:bit):bat[:bit] ", "SQLnil_grp;", "if
any value in l is nil with in a group return true for that group, else false"
]
-[ "sql", "subzero_or_one", "inline function
sql.subzero_or_one(b:bat[:any_1], gp:bat[:oid], gpe:bat[:oid],
no_nil:bit):bat[:any_1];", "", "" ]
+[ "sql", "subzero_or_one", "command
sql.subzero_or_one(b:bat[:any_1], gp:bat[:oid], gpe:bat[:oid],
no_nil:bit):bat[:any_1] ", "SQLsubzero_or_one;", "" ]
[ "sql", "sum", "pattern sql.sum(b:bte, s:lng, e:lng):lng ",
"SQLsum;", "return the sum of groups" ]
[ "sql", "sum", "pattern sql.sum(b:dbl, s:lng, e:lng):dbl ",
"SQLsum;", "return the sum of groups" ]
[ "sql", "sum", "pattern sql.sum(b:flt, s:lng, e:lng):dbl ",
"SQLsum;", "return the sum of groups" ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -16184,7 +16184,7 @@ stdout of test 'MAL-signatures` in direc
[ "sql", "subdelta", "command sql.subdelta(col:bat[:oid],
cand:bat[:oid], uid:bat[:oid], uval:bat[:oid]):bat[:oid] ",
"DELTAsub2;", "Return a single bat of selected delta." ]
[ "sql", "subdelta", "command sql.subdelta(col:bat[:oid],
cand:bat[:oid], uid:bat[:oid], uval:bat[:oid], ins:bat[:oid]):bat[:oid] ",
"DELTAsub;", "Return a single bat of selected delta." ]
[ "sql", "subnull", "command sql.subnull(l:bat[:any_1],
gp:bat[:oid], gpe:bat[:oid], no_nil:bit):bat[:bit] ", "SQLnil_grp;", "if
any value in l is nil with in a group return true for that group, else false"
]
-[ "sql", "subzero_or_one", "inline function
sql.subzero_or_one(b:bat[:any_1], gp:bat[:oid], gpe:bat[:oid],
no_nil:bit):bat[:any_1];", "", "" ]
+[ "sql", "subzero_or_one", "command
sql.subzero_or_one(b:bat[:any_1], gp:bat[:oid], gpe:bat[:oid],
no_nil:bit):bat[:any_1] ", "SQLsubzero_or_one;", "" ]
[ "sql", "sum", "pattern sql.sum(b:bte, s:lng, e:lng):hge ",
"SQLsum;", "return the sum of groups" ]
[ "sql", "sum", "pattern sql.sum(b:bte, s:lng, e:lng):lng ",
"SQLsum;", "return the sum of groups" ]
[ "sql", "sum", "pattern sql.sum(b:dbl, s:lng, e:lng):dbl ",
"SQLsum;", "return the sum of groups" ]
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -3483,6 +3483,41 @@ zero_or_one(ptr ret, const bat *bid)
}
str
+SQLsubzero_or_one(bat *ret, const bat *bid, const bat *gid, const bat *eid,
bit *no_nil)
+{
+ gdk_return r;
+ BAT *ng = NULL, *h = NULL, *g, *b;
+
+ (void)no_nil;
+ (void)eid;
+
+ g = gid ? BATdescriptor(*gid) : NULL;
+ if (g == NULL) {
+ if (g)
+ BBPunfix(g->batCacheid);
+ throw(MAL, "sql.subzero_or_one", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
+ }
+
+ if ((r = BATgroup(&ng, NULL, &h, g, NULL, NULL, NULL, NULL)) ==
GDK_SUCCEED) {
+ lng max = 0;
+
+ if (ng)
+ BBPunfix(ng->batCacheid);
+ BATmax(h, &max);
+ BBPunfix(h->batCacheid);
+ if (max != lng_nil && max > 1)
+ throw(SQL, "assert", SQLSTATE(M0M29) "zero_or_one:
cardinality violation, scalar expression expected");
+
+ }
+ BBPunfix(g->batCacheid);
+ if (r == GDK_SUCCEED) {
+ b = bid ? BATdescriptor(*bid) : NULL;
+ BBPkeepref(*ret = b->batCacheid);
+ }
+ return MAL_SUCCEED;
+}
+
+str
SQLall(ptr ret, const bat *bid)
{
BAT *b;
diff --git a/sql/backends/monet5/sql.h b/sql/backends/monet5/sql.h
--- a/sql/backends/monet5/sql.h
+++ b/sql/backends/monet5/sql.h
@@ -115,6 +115,7 @@ sql5_export str mvc_bat_restart_seq(Clie
sql5_export str zero_or_one_error(ptr ret, const bat *bid, const bit *err );
sql5_export str zero_or_one_error_bat(ptr ret, const bat *bid, const bat *err
);
sql5_export str zero_or_one(ptr ret, const bat *bid);
+sql5_export str SQLsubzero_or_one(bat *ret, const bat *b, const bat *gp, const
bat *gpe, bit *no_nil);
sql5_export str SQLall(ptr ret, const bat *bid);
sql5_export str SQLall_grp(bat *ret, const bat *l, const bat *gp, const bat
*gpe, bit *no_nil);
sql5_export str SQLnil(bit *ret, const bat *bid);
diff --git a/sql/backends/monet5/sql.mal b/sql/backends/monet5/sql.mal
--- a/sql/backends/monet5/sql.mal
+++ b/sql/backends/monet5/sql.mal
@@ -362,16 +362,8 @@ command zero_or_one( col:bat[:any_1], er
address zero_or_one_error_bat
comment "if col contains exactly one value return this. Incase of more raise
an exception if err is true else return nil";
-inline function sql.subzero_or_one( b:bat[:any_1], gp:bat[:oid],
gpe:bat[:oid], no_nil:bit) :bat[:any_1];
- (g,e,h) := group.group(gp);
- m := aggr.max(h);
- c0 := calc.isnil(m);
- c01 := calc.not(c0);
- c1 := calc.>(m,1:lng);
- c11 := calc.and(c01,c1);
- sql.assert(c11, "zero_or_one: cardinality violation, scalar expression
expected");
- return zero_or_one := b;
-end sql.subzero_or_one;
+command subzero_or_one( b:bat[:any_1], gp:bat[:oid], gpe:bat[:oid],
no_nil:bit) :bat[:any_1]
+address SQLsubzero_or_one;
command all( col:bat[:any_1]) :any_1
address SQLall
diff --git a/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out
b/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out
--- a/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out
+++ b/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out
@@ -98,10 +98,10 @@ project (
| | | | | | | & REF 2
| | | | | | ) [ "b3a"."open_auction_id" NOT NULL = "o"."open_auction_id" NOT
NULL ]
| | | | | ) [ "o"."open_auction_id" NOT NULL ] [ sys.min no nil ("b3a"."id"
NOT NULL HASHCOL ) NOT NULL as "L2"."L2", "o"."open_auction_id" NOT NULL ]
-| | | | ) [ "L2"."L2" NOT NULL, "o"."open_auction_id" NOT NULL as "L26"."L26" ]
-| | | ) [ "b3"."id" NOT NULL HASHCOL = "L2"."L2" NOT NULL,
"o"."open_auction_id" NOT NULL =* "L26"."L26" NOT NULL ]
-| | ) [ "b3"."increase" NOT NULL, "o"."open_auction_id" NOT NULL as
"L20"."L20" ]
-| ) [ "o"."open_auction_id" NOT NULL = "L20"."L20" NOT NULL ]
+| | | | ) [ "L2"."L2" NOT NULL as "L3"."L3", "o"."open_auction_id" NOT NULL as
"L30"."L30" ]
+| | | ) [ "b3"."id" NOT NULL HASHCOL = "L3"."L3" NOT NULL,
"o"."open_auction_id" NOT NULL =* "L30"."L30" NOT NULL ]
+| | ) [ "b3"."increase" NOT NULL, "o"."open_auction_id" NOT NULL as
"L22"."L22" ]
+| ) [ "o"."open_auction_id" NOT NULL = "L22"."L22" NOT NULL ]
) [ "o"."id" NOT NULL HASHCOL , "o"."open_auction_id" NOT NULL, "o"."initial"
NOT NULL, "o"."reserve" NOT NULL, "o"."aktuell" NOT NULL, "o"."privacy" NOT
NULL, "o"."itemref" NOT NULL, "o"."seller" NOT NULL, "o"."quantity" NOT NULL,
"o"."type" NOT NULL, "o"."start" NOT NULL, "o"."ende" NOT NULL, "o"."%TID%" NOT
NULL, "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date"
NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT
NULL, "b"."%TID%" NOT NULL, "b3"."increase" NOT NULL ]
REF 4 (2)
group by (
@@ -128,13 +128,13 @@ project (
| | | | | | | | | table(sys.bidder) [ "bidder"."id" NOT NULL HASHCOL as
"b2a"."id", "bidder"."open_auction_id" NOT NULL as "b2a"."open_auction_id" ]
COUNT ,
| | | | | | | | | & REF 4
| | | | | | | | ) [ "b2a"."open_auction_id" NOT NULL = "o"."open_auction_id"
NOT NULL ]
-| | | | | | | ) [ "o"."open_auction_id" NOT NULL ] [ sys.max no nil
("b2a"."id" NOT NULL HASHCOL ) NOT NULL as "L4"."L4", "o"."open_auction_id" NOT
NULL ]
-| | | | | | ) [ "L4"."L4" NOT NULL, "o"."open_auction_id" NOT NULL as
"L51"."L51" ]
-| | | | | ) [ "b2"."id" NOT NULL HASHCOL = "L4"."L4" NOT NULL,
"o"."open_auction_id" NOT NULL =* "L51"."L51" NOT NULL ]
-| | | | ) [ "o"."open_auction_id" NOT NULL, "b2"."increase" NOT NULL as
"L5"."L5" ]
-| | | ) [ "o"."open_auction_id" NOT NULL ] [ sys.zero_or_one("L5"."L5" NOT
NULL) NOT NULL as "L6"."L6", "o"."open_auction_id" NOT NULL ]
-| | ) [ "L6"."L6" NOT NULL, "o"."open_auction_id" NOT NULL as "L37"."L37" ]
-| ) [ sys.sql_mul("b3"."increase" NOT NULL, double "2") <= "L6"."L6" NOT NULL,
"o"."open_auction_id" NOT NULL = "L37"."L37" NOT NULL ]
+| | | | | | | ) [ "o"."open_auction_id" NOT NULL ] [ sys.max no nil
("b2a"."id" NOT NULL HASHCOL ) NOT NULL as "L5"."L5", "o"."open_auction_id" NOT
NULL ]
+| | | | | | ) [ "L5"."L5" NOT NULL as "L6"."L6", "o"."open_auction_id" NOT
NULL as "L53"."L53" ]
+| | | | | ) [ "b2"."id" NOT NULL HASHCOL = "L6"."L6" NOT NULL,
"o"."open_auction_id" NOT NULL =* "L53"."L53" NOT NULL ]
+| | | | ) [ "o"."open_auction_id" NOT NULL, "b2"."increase" NOT NULL as
"L7"."L7" ]
+| | | ) [ "o"."open_auction_id" NOT NULL ] [ sys.zero_or_one("L7"."L7" NOT
NULL) NOT NULL as "L10"."L10", "o"."open_auction_id" NOT NULL ]
+| | ) [ "L10"."L10" NOT NULL, "o"."open_auction_id" NOT NULL as "L41"."L41" ]
+| ) [ sys.sql_mul("b3"."increase" NOT NULL, double "2") <= "L10"."L10" NOT
NULL, "o"."open_auction_id" NOT NULL = "L41"."L41" NOT NULL ]
) [ "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" NOT
NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT NULL ]
#Select b.* FROM open_auctions o, bidder b WHERE (select b3.INCREASE from
bidder b3 where b3.id = (select min(b3a.id) from bidder b3a where
b3a.open_auction_id = o.open_auction_id)) * 2 <= (Select b2.INCREASE from
bidder b2 where b2.id = (SELECT MAX(b2a.id) from bidder b2a where
b2a.open_auction_id = o.open_auction_id)) AND o.open_auction_id =
b.open_auction_id order by date, time;
% sys.b, sys.b, sys.b, sys.b, sys.b, sys.b # table_name
diff --git
a/sql/test/BugTracker-2016/Tests/memory-consumption-query-PLAN-25joins.Bug-3972.stable.out
b/sql/test/BugTracker-2016/Tests/memory-consumption-query-PLAN-25joins.Bug-3972.stable.out
---
a/sql/test/BugTracker-2016/Tests/memory-consumption-query-PLAN-25joins.Bug-3972.stable.out
+++
b/sql/test/BugTracker-2016/Tests/memory-consumption-query-PLAN-25joins.Bug-3972.stable.out
@@ -88,7 +88,7 @@ stdout of test 'memory-consumption-query
% .plan # table_name
% rel # name
% clob # type
-% 2776 # length
+% 2730 # length
top N (
| project (
| | project (
@@ -169,7 +169,7 @@ top N (
| | | | | ) [ "a3"."t3pkcol" NOT NULL HASHCOL = "table1"."t1cold113" ],
| | | | | table(sys.table12) [ "table12"."t12cola1" ] COUNT
| | | | ) [ "table12"."t12cola1" = "table1"."t1cola1" ]
-| | | ) [ (((((((((((((((clob[char["table1"."t1cold1"]] as "table1"."t1cold1")
FILTER ilike (clob "%a%", clob "")) or ((clob[char["table1"."t1cola1"]] as
"table1"."t1cola1") FILTER ilike (clob "%a%", clob ""))) or
((clob[char["table1"."t1colb1"]] as "table1"."t1colb1") FILTER ilike (clob
"%a%", clob ""))) or ((clob[char["table1"."t1cola11"]] as "table1"."t1cola11")
FILTER ilike (clob "%business%", clob ""))) or ("table1"."t1colc91" >=
timestamp(7)[char(19) "2016-03-21 05:00:00"])) or ("table1"."t1cola101" =
tinyint "1")) or ((clob[char["table1"."t1cola12"]] as "table1"."t1cola12")
FILTER ilike (clob "%Vijay%", clob ""))) or ((clob[char["table2"."t2cola1"]] as
"table2"."t2cola1") ! FILTER ilike (clob "%gmail%", clob ""),
(clob[char["table2"."t2cola1"]] as "table2"."t2cola1") ! FILTER ilike (clob
"%yahoo%", clob ""))) or ((clob[char["table2"."t2cola1"]] as
"table2"."t2cola1") FILTER ilike (clob "%efequitygroup.com%", clob ""))) or
("table4"."t4cola1" = clob "Customer")) or (sys.isnull
("table4"."t4cola2") = boolean "false")) or ("table2"."t2cola81" >= date
"2009-08-31")) or ((("table5"."t5cola1" = clob "BAT") or
((clob[char["table5"."t5cola2"]] as "table5"."t5cola2") FILTER ilike (clob
"%AUSTRALIA%", clob ""))) or ((clob[char["table5"."t5cola2"]] as
"table5"."t5cola2") FILTER ilike (clob "%Monet%", clob ""), "table5"."t5cola3"
= clob "Facebook", "table5"."t5cola5" = clob "new", "table5"."t5cola81" > date
"2015-07-30"))) or ((("table10"."t10cola1" != clob "Completed",
"table9"."t9cola1" = clob "Tasks", "table9"."t9cola91" >= timestamp(7)[char(19)
"2012-01-01 04:32:27"], "table10"."t10cola91" <= timestamp(7)[char(19)
"2013-01-01 04:32:27"]) or ("table9"."t9cola1" = clob "Events",
"table11"."t11cola91" >= timestamp(7)[char(19) "2012-01-01 04:32:27"],
"table11"."t11cola91" <= timestamp(7)[char(19) "2013-01-01 04:32:27"])) or
("table9"."t9cola1" = clob "Calls", "table10"."t10cola91" >=
timestamp(7)[char(19) "2012-01-01 04:32:27"], "table10"."t10cola91" <=
timestamp(7)
[char(19) "2013-01-01 04:32:27"])), (((((((((("table1"."t1cold111" = bigint
"15842000014793046") or ("table1"."t1cold111" = bigint "15842000017701488")) or
("table1"."t1cold111" = bigint "15842000000024019")) or ("table1"."t1cold111" =
bigint "15842000000074007")) or ("table1"."t1cold111" = bigint
"15842000009358096")) or ("table1"."t1cold111" = bigint "15842000010487625"))
or ("table1"."t1cold111" = bigint "15842000006731919")) or
("table1"."t1cold111" = bigint "15842000002590112")) or ("table1"."t1cold111" =
bigint "15842000000019001")) or ("table1"."t1cold111" = bigint
"15842000014923682")) or ("table1"."t1cold111" = bigint "15842000027547249"))
or (("table12"."t12cola1" = clob[bigint "15842000280111951"]) or
("table12"."t12cola1" = clob[bigint "15842000280163015"])) ]
+| | | ) [ (((((((((((((((clob[char["table1"."t1cold1"]] as "table1"."t1cold1")
FILTER ilike (clob "%a%", clob "")) or ((clob[char["table1"."t1cola1"]] as
"table1"."t1cola1") FILTER ilike (clob "%a%", clob ""))) or
((clob[char["table1"."t1colb1"]] as "table1"."t1colb1") FILTER ilike (clob
"%a%", clob ""))) or ((clob[char["table1"."t1cola11"]] as "table1"."t1cola11")
FILTER ilike (clob "%business%", clob ""))) or ("table1"."t1colc91" >=
timestamp(7)[char(19) "2016-03-21 05:00:00"])) or ("table1"."t1cola101" =
tinyint "1")) or ((clob[char["table1"."t1cola12"]] as "table1"."t1cola12")
FILTER ilike (clob "%Vijay%", clob ""))) or ((clob[char["table2"."t2cola1"]] as
"table2"."t2cola1") ! FILTER ilike (clob "%gmail%", clob ""),
(clob[char["table2"."t2cola1"]] as "table2"."t2cola1") ! FILTER ilike (clob
"%yahoo%", clob ""))) or ((clob[char["table2"."t2cola1"]] as
"table2"."t2cola1") FILTER ilike (clob "%efequitygroup.com%", clob ""))) or
("table4"."t4cola1" = clob "Customer")) or (sys.isnull
("table4"."t4cola2") = boolean "false")) or ("table2"."t2cola81" >= date
"2009-08-31")) or ((("table5"."t5cola1" = clob "BAT") or
((clob[char["table5"."t5cola2"]] as "table5"."t5cola2") FILTER ilike (clob
"%AUSTRALIA%", clob ""))) or ((clob[char["table5"."t5cola2"]] as
"table5"."t5cola2") FILTER ilike (clob "%Monet%", clob ""), "table5"."t5cola3"
= clob "Facebook", "table5"."t5cola5" = clob "new", "table5"."t5cola81" > date
"2015-07-30"))) or ((("table10"."t10cola1" != clob "Completed",
"table9"."t9cola1" = clob "Tasks", "table9"."t9cola91" >= timestamp(7)[char(19)
"2012-01-01 04:32:27"], "table10"."t10cola91" <= timestamp(7)[char(19)
"2013-01-01 04:32:27"]) or ("table9"."t9cola1" = clob "Events",
timestamp(7)[char(19) "2012-01-01 04:32:27"] <= "table11"."t11cola91" <=
timestamp(7)[char(19) "2013-01-01 04:32:27"])) or ("table9"."t9cola1" = clob
"Calls", timestamp(7)[char(19) "2012-01-01 04:32:27"] <= "table10"."t10cola91"
<= timestamp(7)[char(19) "2013-01-01 04:32:27"])), ((((((((((
"table1"."t1cold111" = bigint "15842000014793046") or ("table1"."t1cold111" =
bigint "15842000017701488")) or ("table1"."t1cold111" = bigint
"15842000000024019")) or ("table1"."t1cold111" = bigint "15842000000074007"))
or ("table1"."t1cold111" = bigint "15842000009358096")) or
("table1"."t1cold111" = bigint "15842000010487625")) or ("table1"."t1cold111" =
bigint "15842000006731919")) or ("table1"."t1cold111" = bigint
"15842000002590112")) or ("table1"."t1cold111" = bigint "15842000000019001"))
or ("table1"."t1cold111" = bigint "15842000014923682")) or
("table1"."t1cold111" = bigint "15842000027547249")) or (("table12"."t12cola1"
= clob[bigint "15842000280111951"]) or ("table12"."t12cola1" = clob[bigint
"15842000280163015"])) ]
| | ) [ "table1"."t1pkcol" NOT NULL HASHCOL , "table1"."t1cola82",
"table2"."t2cola10", "table1"."t1cola1", "table1"."t1cola91", "a1"."t3cola1",
"table2"."t2cola82" ]
| ) [ "table1"."t1pkcol" NOT NULL HASHCOL , "table1"."t1cola82",
"table2"."t2cola10", "table1"."t1cola1", "table1"."t1cola91", "a1"."t3cola1" ]
[ "table2"."t2cola82" ]
) [ bigint "10", bigint "0" ]
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list