From 352ce1b596758403ab9d439b06267fec4d191a58 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 8 Dec 2010 14:28:06 +0200 Subject: Bug #57954: BIT_AND function returns incorrect results when semijoin=on When setting the aggregate function as having no rows to report the function no_rows_in_result() was calling Item_sum::reset(). However this function in addition to cleaning up the aggregate value by calling aggregator_clear() was also adding the current value to the aggregate value by calling aggregator_add(). Fixed by making no_rows_in_result() to call aggregator_clear() directly. Renamed Item_sum::reset to Item_sum::reset_and_add() to and added a comment to avoid misinterpretation of what the function does. --- mysql-test/r/func_group_innodb.result | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'mysql-test/r/func_group_innodb.result') diff --git a/mysql-test/r/func_group_innodb.result b/mysql-test/r/func_group_innodb.result index 908e85c1652..8412317c91d 100644 --- a/mysql-test/r/func_group_innodb.result +++ b/mysql-test/r/func_group_innodb.result @@ -145,3 +145,50 @@ select count(*), min(7), max(7) from t2m, t1i; count(*) min(7) max(7) 0 NULL NULL drop table t1m, t1i, t2m, t2i; +# +# Bug #57954: BIT_AND function returns incorrect results when +# semijoin=on +CREATE TABLE c ( +pk INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO c VALUES (11,NULL); +INSERT INTO c VALUES (16,'c'); +CREATE TABLE bb ( +pk INT, +col_varchar_key VARCHAR(1), +PRIMARY KEY (pk), +KEY col_varchar_key (col_varchar_key) +) ENGINE=InnoDB; +INSERT INTO bb VALUES (10,NULL); +SELECT straight_join BIT_AND(c.pk) +FROM +bb, c +WHERE c.col_varchar_key='ABC' +ORDER BY c.pk; +BIT_AND(c.pk) +18446744073709551615 +DROP TABLE c,bb; +# +# Bug #58050: BIT_OR and BIT_XOR return incorrect results when +# semijoin=on +# +CREATE TABLE t1 (pk INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1, 1, 1); +CREATE TABLE t2 (pk INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1, 1, NULL); +SELECT t1.* FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1; +pk b c +SELECT BIT_OR(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1; +BIT_OR(t1.b) +0 +SELECT BIT_AND(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1; +BIT_AND(t1.b) +18446744073709551615 +SELECT BIT_XOR(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1; +BIT_XOR(t1.b) +0 +DROP TABLE t1, t2; +End of 5.5 tests -- cgit v1.2.1