Changeset: e4e1ff3fb757 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e4e1ff3fb757
Modified Files:
sql/backends/monet5/bin_partition_by_slice.c
sql/include/sql_relation.h
sql/server/rel_exp.c
sql/server/rel_statistics.c
sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320-Windows.test
sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test
Branch: pp_hashjoin
Log Message:
use only PROP_NUNIQUES, not both PROP and field in sql_exp.
diffs (141 lines):
diff --git a/sql/backends/monet5/bin_partition_by_slice.c
b/sql/backends/monet5/bin_partition_by_slice.c
--- a/sql/backends/monet5/bin_partition_by_slice.c
+++ b/sql/backends/monet5/bin_partition_by_slice.c
@@ -39,15 +39,15 @@
lng
exp_getcard(mvc *sql, sql_rel *rel, sql_exp *e)
{
- BUN est = get_rel_count(rel);
+ BUN est = BUN_NONE;
lng cnt;
sql_subtype *t = exp_subtype(e);
prop *p;
- if (e->nuniques)
- est = e->nuniques;
- else if ((p = find_prop(e->p, PROP_NUNIQUES)))
+ if ((p = find_prop(e->p, PROP_NUNIQUES)) != NULL)
est = (BUN)p->value.dval;
+ else
+ est = get_rel_count(rel);
if (est == BUN_NONE
#if SIZEOF_BUN == SIZEOF_LNG
diff --git a/sql/include/sql_relation.h b/sql/include/sql_relation.h
--- a/sql/include/sql_relation.h
+++ b/sql/include/sql_relation.h
@@ -73,7 +73,6 @@ typedef struct expression {
int shared; /* shared variable */
void *p; /* properties for the optimizer */
str comment;
- ulng nuniques;
} sql_exp;
#define TABLE_PROD_FUNC 1
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -176,8 +176,10 @@ exp_compare(allocator *sa, sql_exp *l, s
e->l = l;
e->r = r;
e->flag = cmptype;
- if (cmptype == cmp_equal)
- e->nuniques = 1;
+ if (cmptype == cmp_equal) {
+ prop *p = e->p = prop_create(sa, PROP_NUNIQUES, (prop *) e->p);
+ p->value.dval = 1;
+ }
if (!has_nil(l) && !has_nil(r))
set_has_no_nil(e);
return e;
@@ -195,8 +197,10 @@ exp_compare2(allocator *sa, sql_exp *l,
e->r = r;
e->f = f;
e->flag = cmptype;
- if (cmptype == cmp_equal)
- e->nuniques = 1;
+ if (cmptype == cmp_equal) {
+ prop *p = e->p = prop_create(sa, PROP_NUNIQUES, (prop *) e->p);
+ p->value.dval = 1;
+ }
if (symmetric)
set_symmetric(e);
if (!has_nil(l) && !has_nil(r) && !has_nil(f))
@@ -251,8 +255,10 @@ exp_in(allocator *sa, sql_exp *l, list *
e->card = MAX(l->card, exps_card);
e->l = l;
e->r = r;
- if (cmptype == cmp_in)
- e->nuniques = list_length(r);
+ if (cmptype == cmp_in) {
+ prop *p = e->p = prop_create(sa, PROP_NUNIQUES, (prop *) e->p);
+ p->value.dval = (dbl) list_length(r);
+ }
assert( cmptype == cmp_in || cmptype == cmp_notin);
e->flag = cmptype;
if (!has_nil(l) && !have_nil(r))
diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c
--- a/sql/server/rel_statistics.c
+++ b/sql/server/rel_statistics.c
@@ -62,7 +62,11 @@ rel_propagate_column_ref_statistics(mvc
found_right = true;
sql_exp *ne;
if ((ne = predicates_find_nid(rel->exps, e->nid)) !=
NULL) {
- e->nuniques = ne->nuniques;
+ prop *p = find_prop(ne->p, PROP_NUNIQUES);
+ if (p && !find_prop(e->p, PROP_NUNIQUES)) {
+ prop *np = e->p = prop_create(sql->sa,
PROP_NUNIQUES, (prop *) e->p);
+ np->value.dval = p->value.dval;
+ }
}
if (!found_left && !found_right)
@@ -184,8 +188,13 @@ rel_propagate_column_ref_statistics(mvc
atom *fval;
prop *est;
if ((found = rel_find_exp(rel, e))) {
- if (found != e && !e->nuniques)
- e->nuniques = found->nuniques;
+ if (found != e && !find_prop(e->p,
PROP_NUNIQUES)) {
+ prop *pp = find_prop(found->p,
PROP_NUNIQUES);
+ if (pp) {
+ prop *np = e->p =
prop_create(sql->sa, PROP_NUNIQUES, (prop *) e->p);
+ np->value.dval = pp->value.dval;
+ }
+ }
if (found /*rel->op != op_table*/) { /* At the
moment don't propagate statistics for table relations */
if ((fval = find_prop_and_get(found->p,
PROP_MAX)))
set_minmax_property(sql, e,
PROP_MAX, fval);
diff --git
a/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320-Windows.test
b/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320-Windows.test
--- a/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320-Windows.test
+++ b/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320-Windows.test
@@ -9,7 +9,7 @@ explain show details copy into cm_tmp fr
----
group by (
| insert(
-| | table("sys"."cm_tmp") [ "cm_tmp"."i" NOT NULL UNIQUE, "cm_tmp"."%TID%" NOT
NULL UNIQUE ]
+| | table("sys"."cm_tmp") [ "cm_tmp"."i", "cm_tmp"."%TID%" NOT NULL UNIQUE ]
| | munion (
| | | project (
| | | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n",
varchar NULL, varchar "NULL", varchar "\\file1", bigint(1) "-1", bigint(1) "0",
int(1) "0", varchar NULL, int(1) "0", int(1) "1", varchar ".", varchar NULL),
@@ -28,7 +28,7 @@ explain show details copy into cm_tmp fr
----
group by (
| insert(
-| | table("sys"."cm_tmp") [ "cm_tmp"."i" NOT NULL UNIQUE, "cm_tmp"."%TID%" NOT
NULL UNIQUE ]
+| | table("sys"."cm_tmp") [ "cm_tmp"."i", "cm_tmp"."%TID%" NOT NULL UNIQUE ]
| | munion (
| | | project (
| | | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n",
varchar NULL, varchar "NULL", varchar "a:\\file1", bigint(1) "-1", bigint(1)
"0", int(1) "0", varchar NULL, int(1) "0", int(1) "1", varchar ".", varchar
NULL),
diff --git a/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test
b/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test
--- a/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test
+++ b/sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.test
@@ -6,7 +6,7 @@ explain show details copy into cm_tmp fr
----
group by (
| insert(
-| | table("sys"."cm_tmp") [ "cm_tmp"."i" NOT NULL UNIQUE, "cm_tmp"."%TID%" NOT
NULL UNIQUE ]
+| | table("sys"."cm_tmp") [ "cm_tmp"."i", "cm_tmp"."%TID%" NOT NULL UNIQUE ]
| | munion (
| | | project (
| | | | table ("sys"."copyfrom"(table("cm_tmp"), varchar "|", varchar "\n",
varchar NULL, varchar "NULL", varchar "/file1", bigint(1) "-1", bigint(1) "0",
int(1) "0", varchar NULL, int(1) "0", int(1) "1", varchar ".", varchar NULL),
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]