Bug #21316 a group by clause crash the server
Submitted: 27 Jul 2006 13:34 Modified: 27 Jul 2006 15:39
Reporter: sebastien lecornet Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.21 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[27 Jul 2006 13:34] sebastien lecornet
Description:
A group by clause with date manipulation crash the server

How to repeat:
mysql> CREATE TABLE test (testdate datetime);
Query OK, 0 rows affected (0.00 sec)

mysql> select count(*), subdate(testdate, interval floor(TIME_TO_SEC(testdate) /600) SECOND) from test group by subdate(testdate, interval floor(TIME_TO_SEC(testdate) /600) SECOND);
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql>

Suggested fix:
-
[27 Jul 2006 15:11] MySQL Verification Team
Thank you for the bug report. I was unable to repeat with current source server
and empty table. The crash happens on your side with the table empty? otherwise
can you provide a dump for to insert data and I will try on my side?

miguel@hegel:~/dbs/5.0> bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.25-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE TABLE test (testdate datetime);
Query OK, 0 rows affected (0.03 sec)

mysql> select count(*), subdate(testdate, interval floor(TIME_TO_SEC(testdate)
    -> /600) SECOND) from test group by subdate(testdate, interval
    -> floor(TIME_TO_SEC(testdate) /600) SECOND);
Empty set (0.01 sec)

mysql> 

Thanks in advance.
[27 Jul 2006 15:17] sebastien lecornet
no data are necessary in this case.
This bug is present in 5.0.21 (test is ok in 5.0.18 and 5.0.19)
[27 Jul 2006 15:25] Martin Friebe
the following crashes (freebsd port build)

show variables like 'version';
 +---------------+------------+
| Variable_name | Value      |
+---------------+------------+
| version       | 5.0.22-log |
+---------------+------------+
1 row in set (0.02 sec)

drop table if exists test;
create table test (testdate datetime  not null );
insert into test select "2006-01-01";insert into test select "2006-01-04 11:58";insert into test select "2006-01-04 11:58";insert into test select "2006-01-04 12:00";

select count(*), subdate(testdate, interval floor(TIME_TO_SEC(testdate) /600) SECOND) from test group by subdate(testdate, interval floor(TIME_TO_SEC(testdate) /600) SECOND);

ERROR 2013 (HY000): Lost connection to MySQL server during query
[27 Jul 2006 15:29] Martin Friebe
it looks like bug #19490 maybe ?
[27 Jul 2006 15:39] MySQL Verification Team
Thank you for the feedback. I am closing this bug as fixed in source
tree.

Output for second case reported:

mysql> select count(*), subdate(testdate, interval floor(TIME_TO_SEC(testdate) /600)
    -> SECOND) from test group by subdate(testdate, interval
    -> floor(TIME_TO_SEC(testdate) /600) SECOND);
+----------+----------------------------------------------------------------------+
| count(*) | subdate(testdate, interval floor(TIME_TO_SEC(testdate) /600)
SECOND) |
+----------+----------------------------------------------------------------------+
|        1 | 2006-01-01 00:00:00                                                  | 
|        2 | 2006-01-04 11:56:49                                                  | 
|        1 | 2006-01-04 11:58:48                                                  | 
+----------+----------------------------------------------------------------------+
3 rows in set (0.01 sec)

mysql> select version();
+--------------+
| version()    |
+--------------+
| 5.0.25-debug | 
+--------------+
1 row in set (0.00 sec)

mysql>