Bug #9577 UNION ALL with + INTERVAL N DAY crashes server
Submitted: 2 Apr 2005 5:22 Modified: 5 May 2005 16:14
Reporter: Rob LoPresti Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S2 (Serious)
Version:5.0.3 OS:Any (any)
Assigned to: CPU Architecture:Any

[2 Apr 2005 5:22] Rob LoPresti
Description:
I found that the server would crash under several different circumstances, notably if I used INTERVAL N DAY or a date function in a query some time after UNION ALL.

How to repeat:
DROP DATABASE IF EXISTS bug_demo;
CREATE DATABASE IF NOT EXISTS bug_demo;
USE bug_demo;
CREATE TABLE bug_table (
	bug_date	DATE
) TYPE=InnoDB;
INSERT INTO bug_table VALUES ('2005-01-01');

SELECT bug_date
FROM bug_table
UNION ALL
SELECT bug_date + INTERVAL 1 DAY
FROM bug_table;

=================
OR, without even using a specific database:
SELECT now() UNION ALL SELECT now();
=================

either of these queries crash the server for me.
[2 Apr 2005 17:33] MySQL Verification Team
Back trace:

(gdb) bt
#0  0x0817f9e4 in Field::make_field (this=0x8ef7258, field=0xbe3fef6c) at field.cc:476
#1  0x0812a181 in Item_field::make_field (this=0x8ef7390, tmp_field=0xbe3fef6c) at item.cc:3083
#2  0x0819fa75 in Protocol::send_fields (this=0x8ed9d58, list=0x8ed94e8, flags=5) at protocol.cc:546
#3  0x08195d37 in select_send::send_fields (this=0x8ef5cd0, list=@0x8ed94e8, flags=5) at sql_class.cc:835
#4  0x08208a21 in do_select (join=0x8ef2510, fields=0x8ed94e8, table=0x0, procedure=0x0) at sql_select.cc:8757
#5  0x081f7901 in JOIN::exec (this=0x8ef2510) at sql_select.cc:1634
#6  0x081f879c in mysql_select (thd=0x8ed9308, rref_pointer_array=0x8ef5b5c, tables=0x8ed9380, wild_num=0,
    fields=@0x8ed94e8, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0,
    select_options=268435456, result=0x8ef5cd0, unit=0x8ed9354, select_lex=0x8ef5a38) at sql_select.cc:2051
#7  0x082e0af7 in st_select_lex_unit::exec (this=0x8ed9354) at sql_union.cc:555
#8  0x082df311 in mysql_union (thd=0x8ed9308, lex=0x8ed9348, result=0x8ef5cd0, unit=0x8ed9354,
    setup_tables_done_option=0) at sql_union.cc:34
#9  0x081f378c in handle_select (thd=0x8ed9308, lex=0x8ed9348, result=0x8ef5cd0, setup_tables_done_option=0)
    at sql_select.cc:217
#10 0x081c05e1 in mysql_execute_command (thd=0x8ed9308) at sql_parse.cc:2382
#11 0x081c8225 in mysql_parse (thd=0x8ed9308, inBuf=0x8ef5750 "SELECT now() UNION ALL SELECT now()", length=35)
    at sql_parse.cc:5156
#12 0x081be8ce in dispatch_command (command=COM_QUERY, thd=0x8ed9308, packet=0x8eed6f1 "", packet_length=36)
    at sql_parse.cc:1647
#13 0x081be17d in do_command (thd=0x8ed9308) at sql_parse.cc:1453
#14 0x081bd308 in handle_one_connection (arg=0x8ed9308) at sql_parse.cc:1110
#15 0xb7e4514b in pthread_start_thread () from /lib/libpthread.so.0
#16 0xb7e451df in pthread_start_thread_event () from /lib/libpthread.so.0
#17 0xb7d7850a in clone () from /lib/libc.so.6
[25 Apr 2005 5:20] Rob LoPresti
I'm no longer seeing this problem with Version 5.0.4
[5 May 2005 16:14] MySQL Verification Team
I wasn't able reproduce it with latest 5.0 BK tree.
Marked as "Closed".