At file:///home/bell/maria/bzr/work-maria-5.1-lb611379/ ------------------------------------------------------------ revno: 2897 revision-id: sanja@askmonty.org-20100810030810-q290n2tcc9uc4xg3 parent: monty@mysql.com-20100809170542-ewa2awm6pcoi1ipy committer: sanja@askmonty.org branch nick: work-maria-5.1-lb611379 timestamp: Tue 2010-08-10 06:08:10 +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-10 03:08:10 +0000 @@ -1713,4 +1713,60 @@ NULL NULL NULL NULL NULL drop table t1; # +#test for LP Bug#611379 +# +CREATE TABLE `t1` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`col_int_key` int(11) DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `col_int_key` (`col_int_key`), +KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`) +) ENGINE=MyISAM AUTO_INCREMENT=30 DEFAULT CHARSET=latin1; +INSERT INTO `t1` VALUES (10,8,'v'); +INSERT INTO `t1` VALUES (11,9,'r'); +INSERT INTO `t1` VALUES (12,9,'a'); +INSERT INTO `t1` VALUES (13,186,'m'); +INSERT INTO `t1` VALUES (14,NULL,'y'); +INSERT INTO `t1` VALUES (15,2,'j'); +INSERT INTO `t1` VALUES (16,3,'d'); +INSERT INTO `t1` VALUES (17,0,'z'); +INSERT INTO `t1` VALUES (18,133,'e'); +INSERT INTO `t1` VALUES (19,1,'h'); +INSERT INTO `t1` VALUES (20,8,'b'); +INSERT INTO `t1` VALUES (21,5,'s'); +INSERT INTO `t1` VALUES (22,5,'e'); +INSERT INTO `t1` VALUES (23,8,'j'); +INSERT INTO `t1` VALUES (24,6,'e'); +INSERT INTO `t1` VALUES (25,51,'f'); +INSERT INTO `t1` VALUES (26,4,'v'); +INSERT INTO `t1` VALUES (27,7,'x'); +INSERT INTO `t1` VALUES (28,6,'m'); +INSERT INTO `t1` VALUES (29,4,'c'); +CREATE TABLE `t2` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`col_int_key` int(11) DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `col_int_key` (`col_int_key`), +KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`) +) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; +INSERT INTO `t2` VALUES (10,8,NULL); +CREATE TABLE `t3` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`col_int_key` int(11) DEFAULT NULL, +`col_varchar_key` varchar(1) DEFAULT NULL, +PRIMARY KEY (`pk`), +KEY `col_int_key` (`col_int_key`), +KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`) +) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; +INSERT INTO `t3` VALUES (1,7,'f'); +SELECT SUM( DISTINCT table1 .`pk` ) FROM t3 table1 STRAIGHT_JOIN ( t2 table2 JOIN t1 ON table2 .`col_varchar_key` ) ON table2 .`pk` ; +SUM( DISTINCT table1 .`pk` ) +NULL +SELECT * FROM ( SELECT SUM( DISTINCT table1 .`pk` ) FROM t3 table1 STRAIGHT_JOIN ( t2 table2 JOIN t1 ON table2 .`col_varchar_key` ) ON table2 .`pk` ) AS t1; +SUM( DISTINCT table1 .`pk` ) +NULL +drop table t1,t2,t3; +# 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-10 03:08:10 +0000 @@ -1082,6 +1082,61 @@ from t1 a, t1 b; select *, f1 = f2 from t1; drop table t1; + +--echo # +--echo #test for LP Bug#611379 +--echo # +CREATE TABLE `t1` ( + `pk` int(11) NOT NULL AUTO_INCREMENT, + `col_int_key` int(11) DEFAULT NULL, + `col_varchar_key` varchar(1) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `col_int_key` (`col_int_key`), + KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`) +) ENGINE=MyISAM AUTO_INCREMENT=30 DEFAULT CHARSET=latin1; +INSERT INTO `t1` VALUES (10,8,'v'); +INSERT INTO `t1` VALUES (11,9,'r'); +INSERT INTO `t1` VALUES (12,9,'a'); +INSERT INTO `t1` VALUES (13,186,'m'); +INSERT INTO `t1` VALUES (14,NULL,'y'); +INSERT INTO `t1` VALUES (15,2,'j'); +INSERT INTO `t1` VALUES (16,3,'d'); +INSERT INTO `t1` VALUES (17,0,'z'); +INSERT INTO `t1` VALUES (18,133,'e'); +INSERT INTO `t1` VALUES (19,1,'h'); +INSERT INTO `t1` VALUES (20,8,'b'); +INSERT INTO `t1` VALUES (21,5,'s'); +INSERT INTO `t1` VALUES (22,5,'e'); +INSERT INTO `t1` VALUES (23,8,'j'); +INSERT INTO `t1` VALUES (24,6,'e'); +INSERT INTO `t1` VALUES (25,51,'f'); +INSERT INTO `t1` VALUES (26,4,'v'); +INSERT INTO `t1` VALUES (27,7,'x'); +INSERT INTO `t1` VALUES (28,6,'m'); +INSERT INTO `t1` VALUES (29,4,'c'); +CREATE TABLE `t2` ( + `pk` int(11) NOT NULL AUTO_INCREMENT, + `col_int_key` int(11) DEFAULT NULL, + `col_varchar_key` varchar(1) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `col_int_key` (`col_int_key`), + KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`) +) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; +INSERT INTO `t2` VALUES (10,8,NULL); +CREATE TABLE `t3` ( + `pk` int(11) NOT NULL AUTO_INCREMENT, + `col_int_key` int(11) DEFAULT NULL, + `col_varchar_key` varchar(1) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `col_int_key` (`col_int_key`), + KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`) +) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; +INSERT INTO `t3` VALUES (1,7,'f'); + +SELECT SUM( DISTINCT table1 .`pk` ) FROM t3 table1 STRAIGHT_JOIN ( t2 table2 JOIN t1 ON table2 .`col_varchar_key` ) ON table2 .`pk` ; +SELECT * FROM ( SELECT SUM( DISTINCT table1 .`pk` ) FROM t3 table1 STRAIGHT_JOIN ( t2 table2 JOIN t1 ON table2 .`col_varchar_key` ) ON table2 .`pk` ) AS t1; +drop table t1,t2,t3; + --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-10 03:08:10 +0000 @@ -949,6 +949,7 @@ { DBUG_ASSERT(args[0]->fixed); + null_value= maybe_null= TRUE; table_field_type= args[0]->field_type(); /* Adjust tmp table type according to the chosen aggregation type */