Bug #714 WITH ROLLUP crashes server
Submitted: 24 Jun 2003 14:11 Modified: 26 Aug 2003 9:49
Reporter: Venu Anuganti Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.1 OS:Linux (Linux)
Assigned to: Michael Widenius CPU Architecture:Any

[24 Jun 2003 14:11] Venu Anuganti
Description:
"GROUP BY <column_name> WITH ROLLUP" command crashes the server in sql_select.cc 
file, Note that it hapens even with 4.1 or older clients. 
 
Here is the server backtrace: 
 
Program received signal SIGSEGV, Segmentation fault. 
[Switching to Thread 1104616752 (LWP 32710)] 
0x08187edb in test_if_skip_sort_order (tab=0x8b96ac4, order=0x8b95c68, 
select_limit=2779096485, no_changes=false) 
    at sql_select.cc:6389 
6389          if (table->used_keys & (((key_map) 1 << ref_key))) 
(gdb) bt 
#0  0x08187edb in test_if_skip_sort_order (tab=0x8b96ac4, order=0x8b95c68, 
select_limit=2779096485, no_changes=false) 
    at sql_select.cc:6389 
#1  0x08188263 in create_sort_index (thd=0xa5a5a5a5, tab=0x8b96ac4, order=0x8b95c68, 
filesort_limit=2779096485, 
    select_limit=2779096485) at sql_select.cc:6536 
#2  0x0817bb34 in JOIN::exec() (this=0x8b95ca8) at sql_select.cc:1284 
#3  0x0817c00c in mysql_select(THD*, Item***, st_table_list*, unsigned, List<Item>&, Item*, 
unsigned, st_order*, st_order*, Item*, st_order*, unsigned long, select_result*, 
st_select_lex_unit*, st_select_lex*, bool) (thd=0x8b91028, 
    rref_pointer_array=0xa5a5a5a5, tables=0xa5a5a5a5, wild_num=2779096485, 
fields=@0xa5a5a5a5, conds=0xa5a5a5a5, 
    og_num=2779096485, order=0xa5a5a5a5, group=0xa5a5a5a5, having=0xa5a5a5a5, 
proc_param=0xa5a5a5a5, 
    select_options=17339392, result=0x8b95c98, unit=0x8b912ac, select_lex=0x8b9139c, 
tables_and_fields_initied=false) 
    at sql_select.cc:1397 
#4  0x081788e0 in handle_select(THD*, st_lex*, select_result*) (thd=0x8b91028, 
lex=0x8b912a0, result=0x8b95c98) 
    at sql_select.cc:173 
#5  0x081576cf in mysql_execute_command(THD*) (thd=0x8b91028) at sql_parse.cc:2049 
#6  0x0815baeb in mysql_parse(THD*, char*, unsigned) (thd=0x8b91028, 
    inBuf=0x8b95a08 "SELECT i, COUNT(*) FROM t GROUP BY i WITH ROLLUP", 
length=146346656) at sql_parse.cc:3619 
#7  0x0815573a in dispatch_command(enum_server_command, THD*, char*, unsigned) 
(command=COM_QUERY, thd=0x8b91028, 
    packet=0x8b94f29 "SELECT i, COUNT(*) FROM t GROUP BY i WITH ROLLUP", 
packet_length=49) at sql_parse.cc:1294 
#8  0x08154fc2 in do_command(THD*) (thd=0x8b91028) at sql_parse.cc:1094 
#9  0x081544d5 in handle_one_connection (arg=0xa5a5a5a5) at sql_parse.cc:876 
#10 0x40032332 in start_thread () from /lib/tls/libpthread.so.0 
 
 
 

How to repeat:
mysql> use test 
Database changed 
mysql> DROP TABLE IF EXISTS t; 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> CREATE TABLE t ( i int ); 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> INSERT INTO t SET i = 100; 
Query OK, 1 row affected (0.00 sec) 
 
mysql> SELECT i, COUNT(*) FROM t GROUP BY i; 
+------+----------+ 
| i    | COUNT(*) | 
+------+----------+ 
|  100 |        1 | 
+------+----------+ 
1 row in set (0.00 sec) 
 
mysql> SELECT i, COUNT(*) FROM t GROUP BY i WITH ROLLUP; 
ERROR 2013: Lost connection to MySQL server during query
[28 Jun 2003 11:22] MySQL Verification Team
Patch has been sent for approval.
[26 Aug 2003 9:49] Michael Widenius
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

This problem only happen if all tables used in ROLLUP where 'const' tables.
Fix will be in 4.1.1 binary release