Changeset: b18f217ca6c1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b18f217ca6c1
Modified Files:
sql/backends/monet5/sql_statement.c
sql/server/rel_select.c
sql/test/BugTracker-2019/Tests/duplicates-not-eliminated-long-CASE-stmt.Bug-6697.test
sql/test/miscellaneous/Tests/anti_join_plan.test
Branch: default
Log Message:
use new thetaselect for 'is distinct from'
Simply use is-semantics
diffs (191 lines):
diff --git a/sql/backends/monet5/sql_statement.c
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -1728,64 +1728,49 @@ stmt_uselect(backend *be, stmt *op1, stm
k = getDestVar(q);
} else {
assert (cmptype != cmp_filter);
- if (is_semantics) {
- assert(cmptype == cmp_equal || cmptype == cmp_notequal);
- if (cmptype == cmp_notequal)
- anti = !anti;
- q = newStmtArgs(mb, algebraRef, selectRef, 9);
- if (q == NULL)
- goto bailout;
- q = pushArgument(mb, q, l);
- if (sub && !op1->cand) {
- q = pushArgument(mb, q, sub->nr);
- } else {
- assert(!sub || op1->cand == sub);
- sub = NULL;
- }
- q = pushArgument(mb, q, r);
- q = pushArgument(mb, q, r);
- q = pushBit(mb, q, TRUE);
- q = pushBit(mb, q, TRUE);
- q = pushBit(mb, q, anti);
+ q = newStmt(mb, algebraRef, thetaselectRef);
+ if (q == NULL)
+ goto bailout;
+ q = pushArgument(mb, q, l);
+ if (sub && !op1->cand) {
+ q = pushArgument(mb, q, sub->nr);
} else {
- q = newStmt(mb, algebraRef, thetaselectRef);
- if (q == NULL)
- goto bailout;
- q = pushArgument(mb, q, l);
- if (sub && !op1->cand) {
- q = pushArgument(mb, q, sub->nr);
- } else {
- assert(!sub || op1->cand == sub);
- q = pushNilBat(mb, q);
- sub = NULL;
- }
- q = pushArgument(mb, q, r);
- switch (cmptype) {
- case cmp_equal:
+ assert(!sub || op1->cand == sub);
+ q = pushNilBat(mb, q);
+ sub = NULL;
+ }
+ q = pushArgument(mb, q, r);
+ switch (cmptype) {
+ case cmp_equal:
+ if (is_semantics)
+ q = pushStr(mb, q, anti?"ne":"eq");
+ else
q = pushStr(mb, q, anti?"!=":"==");
- break;
- case cmp_notequal:
+ break;
+ case cmp_notequal:
+ if (is_semantics)
+ q = pushStr(mb, q, anti?"eq":"ne");
+ else
q = pushStr(mb, q, anti?"==":"!=");
- break;
- case cmp_lt:
- q = pushStr(mb, q, anti?">=":"<");
- break;
- case cmp_lte:
- q = pushStr(mb, q, anti?">":"<=");
- break;
- case cmp_gt:
- q = pushStr(mb, q, anti?"<=":">");
- break;
- case cmp_gte:
- q = pushStr(mb, q, anti?"<":">=");
- break;
- default:
- TRC_ERROR(SQL_EXECUTION, "Impossible select
compare\n");
- if (q)
- freeInstruction(q);
- q = NULL;
- goto bailout;
- }
+ break;
+ case cmp_lt:
+ q = pushStr(mb, q, anti?">=":"<");
+ break;
+ case cmp_lte:
+ q = pushStr(mb, q, anti?">":"<=");
+ break;
+ case cmp_gt:
+ q = pushStr(mb, q, anti?"<=":">");
+ break;
+ case cmp_gte:
+ q = pushStr(mb, q, anti?"<":">=");
+ break;
+ default:
+ TRC_ERROR(SQL_EXECUTION, "Impossible select compare\n");
+ if (q)
+ freeInstruction(q);
+ q = NULL;
+ goto bailout;
}
}
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -2835,51 +2835,17 @@ rel_logical_exp(sql_query *query, sql_re
char *compare_op = n->next->data.sval;
int quantifier = 0;
int is_semantics = 0;
- bool is_distinct_from = false;
if (n->next->next->next)
quantifier = n->next->next->next->data.i_val + 1;
assert(quantifier == 0 || quantifier == 1 || quantifier == 2 ||
quantifier == 3 || quantifier == 4);
if (quantifier >= 3) {
- if (quantifier == 4) {
- is_distinct_from = true;
+ if (quantifier == 4)
compare_op = "<>";
- }
quantifier = 0;
is_semantics = 1;
}
- if (is_distinct_from) {
- sql_exp* ls = rel_value_exp(query, &rel, lo,
f|sql_farg, ek);
- if (!ls)
- return NULL;
- sql_exp* rs = rel_value_exp(query, &rel, ro,
f|sql_farg, ek);
- if (!rs)
- return NULL;
-
- bool ls_is_non_null_atom = exp_is_atom(ls) &&
exp_is_not_null(ls);
- bool rs_is_non_null_atom = exp_is_atom(rs) &&
exp_is_not_null(rs);
-
- if (ls_is_non_null_atom || rs_is_non_null_atom) {
- sql_rel *r = rel_dup(rel);
- sql_rel* l = rel_compare(query, rel, sc, lo,
ro, compare_op, f | sql_or, ek, quantifier, 0);
- if (!l)
- return NULL;
- sql_subtype *t;
- if (!(t =
exp_subtype(rs_is_non_null_atom?ls:rs)))
- return sql_error(sql, 01,
SQLSTATE(42000) "Cannot have a parameter for IS NULL operator");
- sql_exp* e = exp_compare(sql->sa,
rs_is_non_null_atom?ls:rs, exp_atom(sql->sa, atom_general(sql->sa, t, NULL,
0)), cmp_equal);
- set_has_no_nil(e);
- set_semantics(e);
-
- r = rel_select_push_compare_exp_down(sql, r, e,
e->l, e->r, NULL, f | sql_or);
- if (!r)
- return NULL;
- return rel_or(sql, rel, l, r, NULL, NULL, NULL);
- }
- }
-
- /* [NOT] DISTINCT FROM */
return rel_compare(query, rel, sc, lo, ro, compare_op, f, ek,
quantifier, is_semantics);
}
/* Set Member ship */
diff --git
a/sql/test/BugTracker-2019/Tests/duplicates-not-eliminated-long-CASE-stmt.Bug-6697.test
b/sql/test/BugTracker-2019/Tests/duplicates-not-eliminated-long-CASE-stmt.Bug-6697.test
---
a/sql/test/BugTracker-2019/Tests/duplicates-not-eliminated-long-CASE-stmt.Bug-6697.test
+++
b/sql/test/BugTracker-2019/Tests/duplicates-not-eliminated-long-CASE-stmt.Bug-6697.test
@@ -85,7 +85,7 @@ 46
query I rowsort
select count(*) from sys.tracelog() where stmt like '%algebra.thetaselect%'
----
-47
+48
query I rowsort
select count(*) from sys.tracelog() where stmt like '%bat.replace%'
diff --git a/sql/test/miscellaneous/Tests/anti_join_plan.test
b/sql/test/miscellaneous/Tests/anti_join_plan.test
--- a/sql/test/miscellaneous/Tests/anti_join_plan.test
+++ b/sql/test/miscellaneous/Tests/anti_join_plan.test
@@ -27,10 +27,8 @@ algebra.projection
9
algebra.projectionpath
3
-algebra.select
-1
algebra.thetaselect
-2
+3
bat.mirror
1
bat.pack
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]