mirror of
https://github.com/MariaDB/server.git
synced 2025-11-24 06:01:25 +03:00
BUG#30324: Grouping queries with COUNT(DISTINCT bit column) return wrong results
- The bug was caused by COUNT(DISTINCT ...) code using Unique object in
a way that assumed that BIT(N) column occupies a contiguous space in
temp_table->record[0] buffer.
- The fix is to make COUNT(DISTINCT ...) code instruct create_tmp_table to
create temporary table with column of type BIGINT, not BIT(N).
mysql-test/r/type_bit.result:
BUG#30324: Grouping queries with COUNT(DISTINCT bit column) return wrong results
- Testcase
mysql-test/t/type_bit.test:
BUG#30324: Grouping queries with COUNT(DISTINCT bit column) return wrong results
- Testcase
sql/item_sum.cc:
BUG#30324: Grouping queries with COUNT(DISTINCT bit column) return wrong results
- Make COUNT(DISTINCT ...) code instruct create_tmp_table to create
temporary table with BIGINT, not BIT(N) column.
This commit is contained in:
@@ -657,4 +657,19 @@ b
|
||||
#
|
||||
#
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int, b bit(2));
|
||||
INSERT INTO t1 VALUES (3, 2), (2, 3), (2, 0), (3, 2), (3, 1);
|
||||
SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
|
||||
COUNT(DISTINCT b)
|
||||
2
|
||||
2
|
||||
DROP TABLE t1;
|
||||
create table t2 (a int, b bit(2), c char(10));
|
||||
INSERT INTO t2 VALUES (3, 2, 'two'), (2, 3, 'three'), (2, 0, 'zero'),
|
||||
(3, 2, 'two'), (3, 1, 'one');
|
||||
SELECT COUNT(DISTINCT b,c) FROM t2 GROUP BY a;
|
||||
COUNT(DISTINCT b,c)
|
||||
2
|
||||
2
|
||||
DROP TABLE t2;
|
||||
End of 5.0 tests
|
||||
|
||||
Reference in New Issue
Block a user