At file:///home/bell/maria/bzr/work-maria-5.1-lb611379/ ------------------------------------------------------------ revno: 2897 revision-id: sanja@askmonty.org-20100827110519-b0gnykgc417kgi4q parent: monty@mysql.com-20100809170542-ewa2awm6pcoi1ipy committer: sanja@askmonty.org branch nick: work-maria-5.1-lb611379 timestamp: Fri 2010-08-27 14:05:19 +0300 message: Fix for LP bug#611379. maybe_null/null_value flag set to TRUE for Item_sum_distinct. === modified file 'mysql-test/r/func_group.result' --- a/mysql-test/r/func_group.result 2009-11-24 15:26:13 +0000 +++ b/mysql-test/r/func_group.result 2010-08-27 11:05:19 +0000 @@ -1713,4 +1713,16 @@ NULL NULL NULL NULL NULL drop table t1; # +#test for LP Bug#611379 +# +create table t1 (a int not null); +insert into t1 values (3), (1), (2); +select sum(distinct a) from t1 where a < 0; +sum(distinct a) +NULL +select * from (select sum(distinct a) from t1 where a < 0) as t; +sum(distinct a) +NULL +drop table t1; +# End of 5.1 tests === modified file 'mysql-test/t/func_group.test' --- a/mysql-test/t/func_group.test 2009-11-24 15:26:13 +0000 +++ b/mysql-test/t/func_group.test 2010-08-27 11:05:19 +0000 @@ -1082,6 +1082,16 @@ from t1 a, t1 b; select *, f1 = f2 from t1; drop table t1; + +--echo # +--echo #test for LP Bug#611379 +--echo # +create table t1 (a int not null); +insert into t1 values (3), (1), (2); +select sum(distinct a) from t1 where a < 0; +select * from (select sum(distinct a) from t1 where a < 0) as t; +drop table t1; + --echo # --echo End of 5.1 tests === modified file 'sql/item_sum.cc' --- a/sql/item_sum.cc 2010-08-02 09:01:24 +0000 +++ b/sql/item_sum.cc 2010-08-27 11:05:19 +0000 @@ -587,13 +587,11 @@ return TRUE; decimals=0; - maybe_null=0; for (uint i=0 ; i < arg_count ; i++) { if (args[i]->fix_fields(thd, args + i) || args[i]->check_cols(1)) return TRUE; set_if_bigger(decimals, args[i]->decimals); - maybe_null |= args[i]->maybe_null; } result_field=0; max_length=float_length(decimals); @@ -949,6 +947,7 @@ { DBUG_ASSERT(args[0]->fixed); + maybe_null= TRUE; table_field_type= args[0]->field_type(); /* Adjust tmp table type according to the chosen aggregation type */