Below is the list of changes that have just been committed into a local
4.1 repository of igor. When igor does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2414 05/09/08 12:37:16 igor@stripped +3 -0
sql_select.cc:
Fixed bug #12885.
Forced inheritence of the maybe_null flag for the expressions
containing GROUP BY attributes in selects with ROLLUP.
olap.test, olap.result:
Added test case for bug #12885.
sql/sql_select.cc
1.434 05/09/08 12:33:07 igor@stripped +14 -3
Fixed bug #12885.
Forced inheritence of the maybe_null flag for the expressions
containing GROUP BY attributes in selects with ROLLUP.
mysql-test/t/olap.test
1.18 05/09/08 12:32:12 igor@stripped +13 -0
Added test case for bug #12885.
mysql-test/r/olap.result
1.21 05/09/08 12:31:31 igor@stripped +13 -0
Added test case for bug #12885.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: igor
# Host: rurik.mysql.com
# Root: /home/igor/dev/mysql-4.1-0
--- 1.433/sql/sql_select.cc Tue Aug 30 12:29:46 2005
+++ 1.434/sql/sql_select.cc Thu Sep 8 12:33:07 2005
@@ -9277,6 +9277,8 @@
The function replaces occurrences of group by fields in expr
by ref objects for these fields unless they are under aggregate
functions.
+ The function also corrects value of the the maybe_null attribute
+ for the items of all subexpressions containing group by fields.
IMPLEMENTATION
The function recursively traverses the tree of the expr expression,
@@ -9287,6 +9289,9 @@
This substitution is needed GROUP BY queries with ROLLUP if
SELECT list contains expressions over group by attributes.
+ TODO: Some functions are not null-preserving. For those functions
+ updating of the maybe_null attribute is an overkill.
+
EXAMPLES
SELECT a+1 FROM t1 GROUP BY a WITH ROLLUP
SELECT SUM(a)+a FROM t1 GROUP BY a WITH ROLLUP
@@ -9307,6 +9312,7 @@
arg != arg_end; arg++)
{
Item *item= *arg;
+ bool arg_changed= FALSE;
if (item->type() == Item::FIELD_ITEM || item->type() == Item::REF_ITEM)
{
ORDER *group_tmp;
@@ -9318,15 +9324,20 @@
if(!(new_item= new Item_ref(group_tmp->item, 0, item->name)))
return 1; // fatal_error is set
thd->change_item_tree(arg, new_item);
- *changed= TRUE;
+ arg_changed= TRUE;
}
}
}
else if (item->type() == Item::FUNC_ITEM)
{
- if (change_group_ref(thd, (Item_func *) item, group_list, changed))
+ if (change_group_ref(thd, (Item_func *) item, group_list, &arg_changed))
return 1;
}
+ if (arg_changed)
+ {
+ expr->maybe_null= 1;
+ *changed= TRUE;
+ }
}
}
return 0;
@@ -9389,7 +9400,7 @@
}
if (item->type() == Item::FUNC_ITEM)
{
- bool changed= 0;
+ bool changed= FALSE;
if (change_group_ref(thd, (Item_func *) item, group_list, &changed))
return 1;
/*
--- 1.20/mysql-test/r/olap.result Fri Jul 1 07:39:50 2005
+++ 1.21/mysql-test/r/olap.result Thu Sep 8 12:31:31 2005
@@ -516,3 +516,16 @@
1 NULL NULL 2
NULL NULL NULL 2
DROP TABLE t1;
+CREATE TABLE t1 (a int(11) NOT NULL);
+INSERT INTO t1 VALUES (1),(2);
+SELECT * FROM (SELECT a, a + 1, COUNT(*) FROM t1 GROUP BY a WITH ROLLUP) t;
+a a + 1 COUNT(*)
+1 2 1
+2 3 1
+NULL NULL 2
+SELECT * FROM (SELECT a, LENGTH(a), COUNT(*) FROM t1 GROUP BY a WITH ROLLUP) t;
+a LENGTH(a) COUNT(*)
+1 1 1
+2 1 1
+NULL NULL 2
+DROP TABLE t1;
--- 1.17/mysql-test/t/olap.test Wed Jul 27 17:21:46 2005
+++ 1.18/mysql-test/t/olap.test Thu Sep 8 12:32:12 2005
@@ -250,4 +250,17 @@
DROP TABLE t1;
+#
+# Bug #11885: derived table specified by a subquery with
+# ROLLUP over expressions on not nullable group by attributes
+#
+
+CREATE TABLE t1 (a int(11) NOT NULL);
+INSERT INTO t1 VALUES (1),(2);
+
+SELECT * FROM (SELECT a, a + 1, COUNT(*) FROM t1 GROUP BY a WITH ROLLUP) t;
+SELECT * FROM (SELECT a, LENGTH(a), COUNT(*) FROM t1 GROUP BY a WITH ROLLUP) t;
+
+DROP TABLE t1;
+
# End of 4.1 tests
| Thread |
|---|
| • bk commit into 4.1 tree (igor:1.2414) BUG#12885 | igor | 8 Sep |