Changeset: 15c13b271124 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=15c13b271124
Branch: default
Log Message:
merged
diffs (83 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
@@ -2996,15 +2996,6 @@ exp_simplify_math( mvc *sql, sql_exp *e,
}
}
}
- /* move constants to the right, ie c*A = A*c */
- else if (exp_is_atom(le)) {
- l->h->data = re;
- l->h->next->data = le;
- e->f = sql_bind_func(sql, "sys", "sql_mul",
exp_subtype(re), exp_subtype(le), F_FUNC);
- exp_sum_scales(e->f, re, le);
- (*changes)++;
- return e;
- }
/* change a*a into pow(a,2), later change pow(a,2) back
into a*a */
if (/* DISABLES CODE */ (0) && exp_equal(le, re)==0 &&
exp_subtype(le)->type->eclass == EC_FLT) {
/* pow */
@@ -3098,13 +3089,7 @@ exp_simplify_math( mvc *sql, sql_exp *e,
}
}
}
- /* move constants to the right, ie c+A = A+c */
- else if (exp_is_atom(le)) {
- l->h->data = re;
- l->h->next->data = le;
- (*changes)++;
- return e;
- } else if (is_func(le->type)) {
+ if (is_func(le->type)) {
list *ll = le->l;
sql_subfunc *f = le->f;
if (!f->func->s && !strcmp(f->func->base.name,
"sql_add") && list_length(ll) == 2) {
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
@@ -2848,6 +2848,15 @@ rel_binop_(mvc *sql, sql_rel *rel, sql_e
if (card == card_loader)
card = card_none;
+ if (is_commutative(fname) && l->card < r->card) { /* move constants to
the right if possible */
+ sql_subtype *tmp = t1;
+ t1 = t2;
+ t2 = tmp;
+ res = l;
+ l = r;
+ r = res;
+ }
+
/* handle param's early */
if (!t1 || !t2) {
f = sql_resolve_function_with_undefined_parameters(sql, sname,
fname, list_append(list_append(sa_list(sql->sa), t1), t2), type);
diff --git a/sql/test/out2in/Tests/out2in.test
b/sql/test/out2in/Tests/out2in.test
--- a/sql/test/out2in/Tests/out2in.test
+++ b/sql/test/out2in/Tests/out2in.test
@@ -44,7 +44,7 @@ project (
| join (
| | select (
| | | table("sys"."foo") [ "foo"."i" ] COUNT
-| | ) [ ("sys"."sql_mul"(tinyint "2", "foo"."i") > bigint "20") or
("sys"."sql_mul"("foo"."i", tinyint "2") > bigint "400",
"sys"."sql_add"(bigint["foo"."i"], bigint["foo"."i"]) = bigint["foo"."i"]) ],
+| | ) [ ("sys"."sql_mul"("foo"."i", tinyint "2") > bigint "20") or
("sys"."sql_mul"("foo"."i", tinyint "2") > bigint "400",
"sys"."sql_add"(bigint["foo"."i"], bigint["foo"."i"]) = bigint["foo"."i"]) ],
| | table("sys"."bar") [ "bar"."i" ] COUNT
| ) [ "foo"."i" = "bar"."i" ]
) [ "foo"."i", "bar"."i" ]
@@ -56,7 +56,7 @@ project (
| left outer join (
| | select (
| | | table("sys"."foo") [ "foo"."i" ] COUNT
-| | ) [ ("sys"."sql_mul"(tinyint "2", "foo"."i") > bigint "20") or
("sys"."sql_mul"("foo"."i", tinyint "2") > bigint "400",
"sys"."sql_add"(bigint["foo"."i"], bigint["foo"."i"]) = bigint["foo"."i"]) ],
+| | ) [ ("sys"."sql_mul"("foo"."i", tinyint "2") > bigint "20") or
("sys"."sql_mul"("foo"."i", tinyint "2") > bigint "400",
"sys"."sql_add"(bigint["foo"."i"], bigint["foo"."i"]) = bigint["foo"."i"]) ],
| | table("sys"."bar") [ "bar"."i" ] COUNT
| ) [ "foo"."i" = "bar"."i" ]
) [ "foo"."i", "bar"."i" ]
@@ -80,7 +80,7 @@ project (
| join (
| | select (
| | | table("sys"."foo") [ "foo"."i" ] COUNT
-| | ) [ ("sys"."sql_mul"(tinyint "2", "foo"."i") > bigint "20") or
("sys"."sql_mul"("foo"."i", tinyint "2") > bigint "400",
"sys"."sql_add"(bigint["foo"."i"], bigint["foo"."i"]) = bigint["foo"."i"]) ],
+| | ) [ ("sys"."sql_mul"("foo"."i", tinyint "2") > bigint "20") or
("sys"."sql_mul"("foo"."i", tinyint "2") > bigint "400",
"sys"."sql_add"(bigint["foo"."i"], bigint["foo"."i"]) = bigint["foo"."i"]) ],
| | select (
| | | table("sys"."bar") [ "bar"."i", "bar"."j" ] COUNT
| | ) [ "bar"."j" ! * = int "NULL" ]
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list