Description:
When executing an UPDATE containing a subquery and an OR NOT condition, mysqld crashed as follows:
#0 0x00110416 in __kernel_vsyscall ()
#1 0x00581c78 in pthread_kill () from /lib/libpthread.so.0
#2 0x085b0d74 in my_write_core (sig=6) at stacktrace.c:307
#3 0x08213e98 in handle_segfault (sig=6) at mysqld.cc:2638
#4 <signal handler called>
#5 0x00110416 in __kernel_vsyscall ()
#6 0x003e6660 in raise () from /lib/libc.so.6
#7 0x003e8028 in abort () from /lib/libc.so.6
#8 0x003df57e in __assert_fail () from /lib/libc.so.6
#9 0x081f07f6 in Field_long::val_int (this=0x9885b28) at field.cc:3662
#10 0x0816e95d in Item_field::val_int (this=0x98807c0) at item.cc:1981
#11 0x0819efe2 in Arg_comparator::compare_int_signed (this=0x9881294) at item_cmpfunc.cc:1243
#12 0x081a71de in Item_func_eq::val_int (this=0x2fa1) at item_cmpfunc.h:71
#13 0x0816f04b in Item::val_bool (this=0x9881218) at item.cc:184
#14 0x081a0d5f in Item_cond_or::val_int (this=0x98815e8) at item_cmpfunc.cc:4273
#15 0x082a6756 in mysql_update (thd=0x984c010, table_list=0x9880268, fields=@0x984d484, values=@0x984d6b0, conds=0x98815e8, order_num=0, order=0x0,
limit=4294967295, handle_duplicates=DUP_ERROR, ignore=false) at opt_range.h:737
#16 0x08222b55 in mysql_execute_command (thd=0x984c010) at sql_parse.cc:2843
#17 0x0822a02e in mysql_parse (thd=0x984c010, inBuf=0x987ff30 "UPDATE C\nSET pk = 1\nWHERE pk = (\n SELECT 1 FROM A\n)\nOR NOT int_key >= 233", length=73,
found_semicolon=0xa8b33314) at sql_parse.cc:5811
#18 0x0822a921 in dispatch_command (command=COM_QUERY, thd=0x984c010,
packet=0x9871371 "UPDATE C\nSET pk = 1\nWHERE pk = (\n SELECT 1 FROM A\n)\nOR NOT int_key >= 233", packet_length=73) at sql_parse.cc:1051
#19 0x0822ba49 in do_command (thd=0x984c010) at sql_parse.cc:724
#20 0x0821bef0 in handle_one_connection (arg=0x984c010) at sql_connect.cc:1153
#21 0x0057d32f in start_thread () from /lib/libpthread.so.0
#22 0x0049a27e in clone () from /lib/libc.so.6
#9 0x081f07f6 in Field_long::val_int (this=0x9885b28) at field.cc:3662
3662 ASSERT_COLUMN_MARKED_FOR_READ;
How to repeat:
Please paste in mysql client to cause the crash. For some reason, saving the queries as a .test file does not cause it.
CREATE TABLE A (
pk INTEGER AUTO_INCREMENT,
int_key INTEGER NOT NULL,
date_key DATE NOT NULL,
date_nokey DATE NOT NULL,
time_key TIME NOT NULL,
time_nokey TIME NOT NULL,
datetime_key DATETIME NOT NULL,
datetime_nokey DATETIME NOT NULL,
PRIMARY KEY (pk),
KEY (int_key),
KEY (date_key),
KEY (time_key),
KEY (datetime_key)
) ENGINE=Innodb;
CREATE TABLE B (
pk INTEGER AUTO_INCREMENT,
int_key INTEGER NOT NULL,
date_key DATE NOT NULL,
date_nokey DATE NOT NULL,
time_key TIME NOT NULL,
time_nokey TIME NOT NULL,
datetime_key DATETIME NOT NULL,
datetime_nokey DATETIME NOT NULL,
PRIMARY KEY (pk),
KEY (int_key),
KEY (date_key),
KEY (time_key),
KEY (datetime_key)
) ENGINE=Innodb;
INSERT INTO B (
int_key,
date_key, date_nokey,
time_key, time_nokey,
datetime_key, datetime_nokey
) VALUES ('1', '0000-00-00', '0000-00-00', '', '', '2009-4-12 00:00:00', '2009-4-12 00:00:00');
CREATE TABLE C (
pk INTEGER AUTO_INCREMENT,
int_key INTEGER NOT NULL,
date_key DATE NOT NULL,
date_nokey DATE NOT NULL,
time_key TIME NOT NULL,
time_nokey TIME NOT NULL,
datetime_key DATETIME NOT NULL,
datetime_nokey DATETIME NOT NULL,
PRIMARY KEY (pk),
KEY (int_key),
KEY (date_key),
KEY (time_key),
KEY (datetime_key)
) ENGINE=Innodb;
INSERT INTO C (
int_key,
date_key, date_nokey,
time_key, time_nokey,
datetime_key, datetime_nokey
) VALUES ('', '', '', '00:00:00', '00:00:00', '2007-10-14 00:00:00', '2007-10-14 00:00:00');
INSERT INTO C (
int_key,
date_key, date_nokey,
time_key, time_nokey,
datetime_key, datetime_nokey
) VALUES ('1', '2009-10-16', '2009-10-16', '9:28:15', '9:28:15', '2007-9-14 5:34:8', '2007-9-14 5:34:8');
UPDATE C
SET pk = 1
WHERE pk = (
SELECT 1 FROM A
)
OR NOT int_key >= 233;