Changeset: d56497cc5359 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d56497cc5359 Modified Files: sql/server/rel_unnest.c sql/test/BugTracker-2016/Tests/memory-consumption-query-PLAN-25joins.Bug-3972.stable.out sql/test/miscellaneous/Tests/simple_plans.sql sql/test/miscellaneous/Tests/simple_plans.stable.out Branch: Jun2020 Log Message:
Re-write or func into or compare diffs (81 lines): diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c --- a/sql/server/rel_unnest.c +++ b/sql/server/rel_unnest.c @@ -2568,6 +2568,7 @@ rewrite_ifthenelse(mvc *sql, sql_rel *re #define is_gte(sf) (strcmp(sf->func->base.name, ">=") == 0) #define is_lt(sf) (strcmp(sf->func->base.name, "<") == 0) #define is_lte(sf) (strcmp(sf->func->base.name, "<=") == 0) +#define is_or(sf) (strcmp(sf->func->base.name, "or") == 0) static list * rewrite_compare_exps(mvc *sql, list *exps, int* changes) @@ -2591,6 +2592,16 @@ rewrite_compare_exps(mvc *sql, list *exp rewritten = true; (*changes)++; + } else if (is_or(sf)) { + sql_exp *f = l->h->data; + sql_exp *s = l->h->next->data; + + list *l = rewrite_compare_exps(sql, list_append(new_exp_list(sql->sa), f), changes); + list *r = rewrite_compare_exps(sql, list_append(new_exp_list(sql->sa), s), changes); + n->data = e = exp_or(sql->sa, l, r, 0); + + rewritten = true; + (*changes)++; } } 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 -% 2870 # length +% 2736 # length top N ( | project ( | | project ( @@ -177,7 +177,7 @@ top N ( | | | | | ) [ "table1"."t1pkcol" NOT NULL HASHCOL , "table1"."t1cola1", "table1"."t1cola11", "table1"."t1cola12", "table1"."t1cola82", "table1"."t1cola91", "table1"."t1cola101", "table1"."t1colb1", "table1"."t1colb112", "table1"."t1colb113", "table1"."t1colb114", "table1"."t1colc91", "table1"."t1cold1", "table1"."t1cold111", "table1"."t1cold112", "table1"."t1cold113", "table4"."t4cola1", "table4"."t4cola2", "table4"."t4colb111", "table4"."t4colb112", "table4"."t4colb114", "table4"."t4colb115", "table2"."t2cola1", "table2"."t2cola10", "table2"."t2cola81", "table2"."t2cola82", "table2"."t2colc111", "table2"."t2colc112", "table2"."t2colc113", "table2"."t2colc114", "table2"."t2colc115", "table5"."t5cola1", "table5"."t5cola2", "table5"."t5cola3", "table5"."t5cola5", "table5"."t5cola81", "table5"."t5colb113", "lookup3"."t5colb112", "lookup4"."t7colb113", "lookup5"."t8colb114", "lookup11"."t6pkcol" NOT NULL HASHCOL , "lookup21"."t2colb112", "lookup31"."t5pkcol" NOT NULL HASHCOL , "lookup41 "."t7pkcol" NOT NULL HASHCOL , "lookup51"."t8pkcol" NOT NULL HASHCOL , "clookup1"."t6pkcol" NOT NULL HASHCOL , "clookup2"."t2pkcol" NOT NULL HASHCOL , "clookup3"."t5pkcol" NOT NULL HASHCOL , "clookup4"."t7pkcol" NOT NULL HASHCOL , "clookup5"."t8pkcol" NOT NULL HASHCOL , "table9"."t9pkcol" NOT NULL HASHCOL , "table9"."t9cola1", "table9"."t9cola91", "table9"."t9cola111", "table10"."t10pkcol" NOT NULL HASHCOL , "table10"."t10cola1", "table10"."t10cola91", "table11"."t11pkcol" NOT NULL HASHCOL , "table11"."t11cola91", "a1"."t3pkcol" NOT NULL HASHCOL , "a1"."t3cola1", "a2"."t3pkcol" NOT NULL HASHCOL , "a3"."t3pkcol" NOT NULL HASHCOL ], | | | | | 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 ("table4"." t4cola2" ! * = clob "NULL")) 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"] BETWEEN )) 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"] BETWEEN )), sys. or(sys.or(sys.or(sys.or(sys.or(sys.or(sys.or(sys.or(sys.or(sys.or(sys.=("table1"."t1cold111", bigint "15842000014793046"), sys.=("table1"."t1cold111", bigint "15842000017701488")), sys.=("table1"."t1cold111", bigint "15842000000024019")), sys.=("table1"."t1cold111", bigint "15842000000074007")), sys.=("table1"."t1cold111", bigint "15842000009358096")), sys.=("table1"."t1cold111", bigint "15842000010487625")), sys.=("table1"."t1cold111", bigint "15842000006731919")), sys.=("table1"."t1cold111", bigint "15842000002590112")), sys.=("table1"."t1cold111", bigint "15842000000019001")), sys.=("table1"."t1cold111", bigint "15842000014923682")), sys.=("table1"."t1cold111", bigint "15842000027547249")) = boolean "true") or (sys.or(sys.=("table12"."t12cola1", clob[bigint "15842000280111951"]), sys.=("table12"."t12cola1", clob[bigint "15842000280163015"])) = boolean "true") ] +| | | ) [ (((((((((((((((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 ("table4"." t4cola2" ! * = clob "NULL")) 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"] BETWEEN )) 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"] BETWEEN )), (((( (((((("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" NULLS LAST ] ) [ bigint "10", bigint "0" ] diff --git a/sql/test/miscellaneous/Tests/simple_plans.sql b/sql/test/miscellaneous/Tests/simple_plans.sql --- a/sql/test/miscellaneous/Tests/simple_plans.sql +++ b/sql/test/miscellaneous/Tests/simple_plans.sql @@ -4,6 +4,8 @@ create table myx (x uuid, y uuid); plan select * from myx where x in ('1aea00e5db6e0810b554fde31d961965') or y = '1aea00e5db6e0810b554fde31d961965'; plan select * from myx where x in ('1aea00e5db6e0810b554fde31d961965') or y is null; +plan select * from myx where x in ('1aea00e5db6e0810b554fde31d961965', '1aea00e5db6e0810b554fde31d961966') or y = '1aea00e5db6e0810b554fde31d961967'; + insert into myx values ('1aea00e5db6e0810b554fde31d961965', '1aea00e5db6e0810b554fde31d961967'); select * from myx where x in ('1aea00e5db6e0810b554fde31d961966') or y is not null; select * from myx where x in ('1aea00e5db6e0810b554fde31d961966') or y is null; diff --git a/sql/test/miscellaneous/Tests/simple_plans.stable.out b/sql/test/miscellaneous/Tests/simple_plans.stable.out --- a/sql/test/miscellaneous/Tests/simple_plans.stable.out +++ b/sql/test/miscellaneous/Tests/simple_plans.stable.out @@ -27,6 +27,16 @@ project ( | | table(sys.myx) [ "myx"."x", "myx"."y" ] COUNT | ) [ ("myx"."x" = uuid[char(32) "1aea00e5db6e0810b554fde31d961965"]) or ("myx"."y" * = uuid "NULL") ] ) [ "myx"."x", "myx"."y" ] +#plan select * from myx where x in ('1aea00e5db6e0810b554fde31d961965', '1aea00e5db6e0810b554fde31d961966') or y = '1aea00e5db6e0810b554fde31d961967'; +% .plan # table_name +% rel # name +% clob # type +% 207 # length +project ( +| select ( +| | table(sys.myx) [ "myx"."x", "myx"."y" ] COUNT +| ) [ (("myx"."x" = uuid[char(32) "1aea00e5db6e0810b554fde31d961965"]) or ("myx"."x" = uuid[char(32) "1aea00e5db6e0810b554fde31d961966"])) or ("myx"."y" = uuid[char(32) "1aea00e5db6e0810b554fde31d961967"]) ] +) [ "myx"."x", "myx"."y" ] #insert into myx values ('1aea00e5db6e0810b554fde31d961965', '1aea00e5db6e0810b554fde31d961967'); [ 1 ] #select * from myx where x in ('1aea00e5db6e0810b554fde31d961966') or y is not null; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list