Changeset: 729b8ff4b9d4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/729b8ff4b9d4
Modified Files:
sql/server/rel_select.c
sql/test/BugTracker-2026/Tests/7973-groupby-list-null-row-bug.test
Branch: default
Log Message:
properly keep has nil for cube/rollups, fixes bug #7973
diffs (74 lines):
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
@@ -4481,7 +4481,7 @@ lists_cartesian_product_and_distinct(all
}
static list*
-rel_groupings(sql_query *query, sql_rel **rel, symbol *groupby, dlist
*selection, int f, bool grouping_sets, list **sets)
+rel_groupings(sql_query *query, sql_rel **rel, symbol *groupby, dlist
*selection, int f, bool grouping_sets, list **sets, bool *has_nil)
{
mvc *sql = query->sql;
list *exps = new_exp_list(sql->sa);
@@ -4494,7 +4494,7 @@ rel_groupings(sql_query *query, sql_rel
list *next_set = NULL;
if (grouping->token == SQL_GROUPING_SETS) { /* call
recursively, and merge the generated sets */
- list *other = rel_groupings(query, rel, grouping,
selection, f, true, &next_set);
+ list *other = rel_groupings(query, rel, grouping,
selection, f, true, &next_set, has_nil);
if (!other)
return NULL;
exps = list_distinct(list_merge(exps, other, (fdup)
NULL), (fcmp) exp_equal, (fdup) NULL);
@@ -4534,15 +4534,20 @@ rel_groupings(sql_query *query, sql_rel
list_append(set_cols, next_tuple);
}
if (is_sql_group_totals(f)) {
- if (grouping->token == SQL_ROLLUP)
+ if (grouping->token == SQL_ROLLUP) {
next_set = list_rollup(sql,
set_cols);
- else if (grouping->token == SQL_CUBE)
+ *has_nil = true;
+ } else if (grouping->token == SQL_CUBE)
{
next_set =
list_power_set(sql->sa, set_cols);
- else /* the list of sets is not used in
the "GROUP BY a, b, ..." case */
+ *has_nil = true;
+ } else { /* the list of sets is not
used in the "GROUP BY a, b, ..." case */
next_set =
list_append(new_exp_list(sql->sa), set_cols);
+ }
}
- } else if (is_sql_group_totals(f) && grouping_sets) /*
The GROUP BY () case is the global aggregate which is always added by ROLLUP
and CUBE */
+ } else if (is_sql_group_totals(f) && grouping_sets) {
/* The GROUP BY () case is the global aggregate which is always added by ROLLUP
and CUBE */
next_set = list_append(new_exp_list(sql->sa),
new_exp_list(sql->sa));
+ *has_nil = true;
+ }
}
if (is_sql_group_totals(f)) { /* if there are no sets, set the
found one, otherwise calculate cartesian product and merge the distinct ones */
if (!next_set)
@@ -5757,9 +5762,14 @@ rel_where_groupby_nodes(sql_query *query
break;
}
}
- gbe = rel_groupings(query, &rel, sn->groupby,
sn->selection, sql_sel | sql_groupby | *group_totals, false, &sets);
+ bool has_nil = false;
+ gbe = rel_groupings(query, &rel, sn->groupby,
sn->selection, sql_sel | sql_groupby | *group_totals, false, &sets, &has_nil);
if (!gbe)
return NULL;
+ for(node *n = gbe->h; n; n = n->next) {
+ sql_exp *e = n->data;
+ set_has_nil(e);
+ }
}
rel = rel_groupby(sql, rel, gbe);
if (rel && all)
diff --git a/sql/test/BugTracker-2026/Tests/7973-groupby-list-null-row-bug.test
b/sql/test/BugTracker-2026/Tests/7973-groupby-list-null-row-bug.test
--- a/sql/test/BugTracker-2026/Tests/7973-groupby-list-null-row-bug.test
+++ b/sql/test/BugTracker-2026/Tests/7973-groupby-list-null-row-bug.test
@@ -13,6 +13,8 @@ SELECT c0, COUNT(*) AS n FROM br_rollup_
1
20
1
+NULL
+2
-- (2) the same row, four ways of asking "is c0 null?" -- they disagree
-- observed: (10,10,0,'IS NULL -> FALSE',1)
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]