Bug #18006 GROUP BY can corrupt BIT values when multiple bits returned
| Submitted: | 7 Mar 2006 1:07 | Modified: | 7 Mar 2006 1:34 |
|---|---|---|---|
| Reporter: | J Rabbit | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server | Severity: | S2 (Serious) |
| Version: | 5.0.16 | OS: | Windows (Windows 2003) |
| Assigned to: | MySQL Verification Team | CPU Architecture: | Any |
[7 Mar 2006 1:07]
J Rabbit
[7 Mar 2006 1:09]
J Rabbit
Updated title to be more accurate
[7 Mar 2006 1:22]
MySQL Verification Team
Thank you for the bug report.
Please read the Manual regarding the use of BIT columns. See below
the query: select a,b+0,c+0 from test group by a;
mysql> use test
Database changed
mysql> create table test (a int not null, b bit null, c bit null)
-> type=myisam;
Query OK, 0 rows affected, 1 warning (0.06 sec)
mysql> insert into test values (1,1,1),(2,0,0),(3,NULL,NULL);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select a,b+0,c+0 from test group by a;
+---+------+------+
| a | b+0 | c+0 |
+---+------+------+
| 1 | 1 | 1 |
| 2 | 0 | 0 |
| 3 | NULL | NULL |
+---+------+------+
3 rows in set (0.00 sec)
mysql> select a,b,c from test group by a;
+---+------+------+
| a | b | c |
+---+------+------+
| 1 | | ☺ |
| 2 | | |
| 3 | NULL | NULL |
+---+------+------+
3 rows in set (0.00 sec)
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.0.18-nt |
+-----------+
1 row in set (0.00 sec)
mysql>
[7 Mar 2006 1:24]
J Rabbit
I have also been able to repeat this without the GROUP BY by using a combination of joins and order by: mysql> create table test (a int not null, b bit null, c bit null) type=myisam; Query OK, 0 rows affected, 1 warning (0.05 sec) mysql> insert into test values (1,1,1),(2,0,0),(3,NULL,NULL); Query OK, 3 rows affected (0.00 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> select t1.a,t1.b,t1.c from test t1 left join test t2 on t1.a = t2.a; +---+------+------+ | a | b | c | +---+------+------+ | 1 | ☺ | ☺ | | 2 | | | | 3 | NULL | NULL | +---+------+------+ 3 rows in set (0.00 sec) ======================== The value of b in the first row is incorrect in the next two queries: mysql> select t1.a,t1.b,t1.c from test t1 left join test t2 on t1.a = t2.a order by t1.a; +---+------+------+ | a | b | c | +---+------+------+ | 1 | | ☺ | | 2 | | | | 3 | NULL | NULL | +---+------+------+ 3 rows in set (0.00 sec) mysql> select t1.a,t1.b,t1.c from test t1 inner join test t2 on t1.a = t2.a order by t1.a; +---+------+------+ | a | b | c | +---+------+------+ | 1 | | ☺ | | 2 | | | | 3 | NULL | NULL | +---+------+------+ 3 rows in set (0.01 sec)
[7 Mar 2006 1:34]
MySQL Verification Team
Thank you for the feedback: c:\mysql\bin>mysql -uroot test Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 to server version: 5.0.18-nt Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create table test (a int not null, b bit null, c bit null) type=myisam; Query OK, 0 rows affected, 1 warning (0.06 sec) mysql> insert into test values (1,1,1),(2,0,0),(3,NULL,NULL); Query OK, 3 rows affected (0.02 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> select t1.a,t1.b+0,t1.c+0 from test t1 left join test t2 on t1.a = t2.a; +---+--------+--------+ | a | t1.b+0 | t1.c+0 | +---+--------+--------+ | 1 | 1 | 1 | | 2 | 0 | 0 | | 3 | NULL | NULL | +---+--------+--------+ 3 rows in set (0.03 sec) mysql>
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.053 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.