Changeset: fcce0dc7eb96 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fcce0dc7eb96
Modified Files:
sql/server/rel_optimizer.c
sql/test/miscellaneous/Tests/simple_plans.test
Branch: Jan2022
Log Message:
Merged with Jul2021
diffs (49 lines):
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
@@ -3547,13 +3547,18 @@ merge_notequal(mvc *sql, list *exps, int
for (node *n = inequality_groups->h; n; n = n->next) {
list *next = n->data;
sql_exp *first = (sql_exp*) next->h->data;
- list *notin = new_exp_list(sql->sa);
-
- for (node *m = next->h; m; m = m->next) {
- sql_exp *e = m->data;
- list_append(notin, e->r);
- }
- list_append(nexps, exp_in(sql->sa, first->l, notin,
cmp_notin));
+
+ if (list_length(next) > 1) {
+ list *notin = new_exp_list(sql->sa);
+
+ for (node *m = next->h; m; m = m->next) {
+ sql_exp *e = m->data;
+ list_append(notin, e->r);
+ }
+ list_append(nexps, exp_in(sql->sa, first->l,
notin, cmp_notin));
+ } else {
+ list_append(nexps, first);
+ }
}
for (node *n = exps->h; n; n = n->next) {
diff --git a/sql/test/miscellaneous/Tests/simple_plans.test
b/sql/test/miscellaneous/Tests/simple_plans.test
--- a/sql/test/miscellaneous/Tests/simple_plans.test
+++ b/sql/test/miscellaneous/Tests/simple_plans.test
@@ -144,6 +144,16 @@ project (
| ) [ ("tab0"."col1") notin (int(32) "1", int(32) "81") ]
) [ tinyint(1) "1" ]
+# don't rewrite col2 <> 10 into notin
+query T nosort
+plan select 1 from tab0 where col1 <> 1 and col1 <> 81 and col2 <> 10
+----
+project (
+| select (
+| | table("sys"."tab0") [ "tab0"."col1", "tab0"."col2" ]
+| ) [ ("tab0"."col2") != (int(32) "10"), ("tab0"."col1") notin (int(32) "1",
int(32) "81") ]
+) [ tinyint(1) "1" ]
+
query T nosort
plan select 1 from tab0 where col1 <> 1 and col1 <> 81 and (col2 < 0)
----
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list