Bug #46989 | NULL attribute gets lost when "CREATE TABLE AS SELECT ... GROUP BY WITH ROLLUP" | ||
---|---|---|---|
Submitted: | 29 Aug 2009 5:52 | Modified: | 29 Aug 2009 6:09 |
Reporter: | Alexander Barkov | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.1,5.4 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[29 Aug 2009 5:52]
Alexander Barkov
[29 Aug 2009 6:09]
MySQL Verification Team
Thank you for the bug report. Verified as described. c:\dbs>c:\dbs\5.4\bin\mysql -uroot --port=3540 --prompt="mysql 5.4 >" Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.4.4-alpha-Win X64 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql 5.4 >create database estar; Query OK, 1 row affected (0.01 sec) mysql 5.4 >use estar Database changed mysql 5.4 >create table t1 (runid varchar(10) not null, recall double not null); Query OK, 0 rows affected (0.09 sec) mysql 5.4 >insert into t1 values ('xxxx-1',0.1),('xxxx-2',0.2),('xxxx-1',0.3); Query OK, 3 rows affected (0.01 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql 5.4 >select runid, avg(recall) as recall from t1 group by runid with rollup; +--------+---------------------+ | runid | recall | +--------+---------------------+ | xxxx-1 | 0.2 | | xxxx-2 | 0.2 | | NULL | 0.20000000000000004 | +--------+---------------------+ 3 rows in set (0.00 sec) mysql 5.4 >create table t2 as select runid, avg(recall) as recall from t1 group by runid with -> rollup; Query OK, 3 rows affected, 1 warning (0.14 sec) Records: 3 Duplicates: 0 Warnings: 1 mysql 5.4 >show warnings; +---------+------+-------------------------------+ | Level | Code | Message | +---------+------+-------------------------------+ | Warning | 1048 | Column 'runid' cannot be null | +---------+------+-------------------------------+ 1 row in set (0.00 sec) mysql 5.4 >show create table t1; +-------+------------------------------------------------------------------------------------------ | Table | Create Table +-------+------------------------------------------------------------------------------------------ | t1 | CREATE TABLE `t1` ( `runid` varchar(10) NOT NULL, `recall` double NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 | +-------+------------------------------------------------------------------------------------------ 1 row in set (0.00 sec) mysql 5.4 >
[9 Sep 2009 19:50]
Guilhem Bichot
GROUP BY, ROLLUP => Optimizer
[15 Sep 2009 8:16]
Roy Lyseng
Verified that the same problem exists in 5.1.
[9 Jan 2017 6:33]
Joe Walker
I can still see this bug as of MySQL 5.7.16. I ran the test case per the original bug report: ---------- create table t1 (runid varchar(10) not null, recall double not null); insert into t1 values ('xxxx-1',0.1),('xxxx-2',0.2),('xxxx-1',0.3); create table t2 as select runid, avg(recall) as recall from t1 group by runid with rollup; ---------- The result was the same: I received the error "SQL Error (1048): Column 'runid' cannot be null".