Changeset: 5e24b4aad04e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5e24b4aad04e
Modified Files:
sql/backends/monet5/rel_bin.c
sql/server/rel_statistics.c
sql/test/miscellaneous/Tests/unique_keys.test
Branch: Dec2023
Log Message:
fixes for issues #7447 and #7448
ranges queries can have null's and not return NULL, ie fixed
optimizer/statistics
only use full hash index for selects
diffs (47 lines):
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -2592,6 +2592,8 @@ rel2bin_hash_lookup(backend *be, sql_rel
h = stmt_unop(be, s, NULL, hf);
}
}
+ if (n != NULL) /* need to use all cols of the index */
+ return NULL;
if (h && h->nrcols) {
if (!swap_rel) {
return stmt_join(be, idx, h, 0, cmp_equal, 0,
semantics, false);
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
@@ -33,6 +33,10 @@ comparison_find_column(sql_exp *input, s
}
}
+/* multi lo <= col <= hi, maybe still be false even if lo or hi are NULL,
possibly similar for filter on multiple
+ * columns */
+#define comp_single_column(c) (!c->f)
+
static sql_exp *
rel_propagate_column_ref_statistics(mvc *sql, sql_rel *rel, sql_exp *e)
{
@@ -69,7 +73,7 @@ rel_propagate_column_ref_statistics(mvc
*rval_min =
find_prop_and_get(re->p, PROP_MIN), *rval_max = find_prop_and_get(re->p,
PROP_MAX);
/* not semantics found
or if explicitly filtering not null values from the column */
- found_without_semantics
|= !is_semantics(comp) || (comp->flag == cmp_equal && lne && is_anti(comp) &&
exp_is_null(re));
+ found_without_semantics
|= (!is_semantics(comp) && comp_single_column(comp)) || (comp->flag ==
cmp_equal && lne && is_anti(comp) && exp_is_null(re));
still_unique |=
comp->flag == cmp_equal && is_unique(le) && is_unique(re); /* unique if only
equi-joins on unique columns are there */
if (is_full(rel->op) ||
(is_left(rel->op) && found_left) || (is_right(rel->op) && found_right)) /* on
outer joins, min and max cannot be propagated on some cases */
continue;
diff --git a/sql/test/miscellaneous/Tests/unique_keys.test
b/sql/test/miscellaneous/Tests/unique_keys.test
--- a/sql/test/miscellaneous/Tests/unique_keys.test
+++ b/sql/test/miscellaneous/Tests/unique_keys.test
@@ -91,7 +91,7 @@ project (
| | | | table("sys"."testkeys") [ "testkeys"."a" NOT NULL UNIQUE HASHCOL ,
"testkeys"."b" UNIQUE HASHCOL ]
| | | ) [ ("testkeys"."b" UNIQUE HASHCOL ) = (int(32) "1") ],
| | | table("sys"."othertable") [ "othertable"."a" UNIQUE ]
-| | ) [ ("testkeys"."a" NOT NULL UNIQUE HASHCOL ) = ("othertable"."a" NOT NULL
UNIQUE) ]
+| | ) [ ("testkeys"."a" NOT NULL UNIQUE HASHCOL ) = ("othertable"."a" UNIQUE) ]
| ) [ (int(32) "2") <= ("othertable"."a" UNIQUE) <= (int(32) "5") ]
) [ "testkeys"."a" NOT NULL UNIQUE HASHCOL ]
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]