Bug #17216 SP with CREATE TABLE ... PARTITIONED ... crashes on multiple executions
Submitted: 8 Feb 2006 0:22 Modified: 16 Feb 2006 18:57
Reporter: Jonathan Miller Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Partitions Severity:S1 (Critical)
Version:5.1.7 OS:Linux (Linux 32 Bit OS)
Assigned to: Assigned Account CPU Architecture:Any

[8 Feb 2006 0:22] Jonathan Miller
Description:
I tried to break this down as much as possible, but it has to be in SP for this to happen and all the statements are needed to produce the core.

Back Trace:
#0  0x002dc402 in __kernel_vsyscall ()
(gdb) bt
#0  0x002dc402 in __kernel_vsyscall ()
#1  0x00a2855f in pthread_kill () from /lib/libpthread.so.0
#2  0x082ee94b in write_core (sig=30389) at stacktrace.c:220
#3  0x081d19c2 in handle_segfault (sig=11) at mysqld.cc:2197
#4  <signal handler called>
#5  are_partitions_in_table (new_part_info=0xa9e8608, old_part_info=0xa9e8608)
    at sql_partition.cc:218
#6  0x0813dffb in check_partition_info (part_info=0xa9e8608, eng_type=0x3b1c18,
    file=0xb7e2ab08, max_rows=0) at sql_partition.cc:987
#7  0x082b442b in mysql_create_table (thd=0xa9808e8, db=0xa9cb1a0 "test",
    table_name=0xa9cb1a8 "t1", create_info=0xa9d1360, fields=@0xa9d1284, keys=@0xa9d1278,
    internal_tmp_table=false, select_field_count=0) at sql_table.cc:2104
#8  0x081f4aaa in mysql_execute_command (thd=0xa9808e8) at sql_parse.cc:2902
#9  0x082ffd91 in sp_instr_stmt::exec_core (this=0xa9e860c, thd=0x0, nextp=0xa9e860c)
    at sp_head.cc:2319
#10 0x0830040a in sp_lex_keeper::reset_lex_and_exec_core (this=0xa9cb444, thd=0xa9808e8,
    nextp=0x0, open_tables=false, instr=0xa9cb420) at sp_head.cc:2198
#11 0x08304437 in sp_instr_stmt::execute (this=0xa9cb420, thd=0xa9808e8, nextp=0x3b27e0)
    at sp_head.cc:2272
#12 0x08302cf9 in sp_head::execute (this=0xa9cae00, thd=0xa9808e8) at sp_head.cc:1074
#13 0x083033d4 in sp_head::execute_procedure (this=0xa9cae00, thd=0xa9808e8, args=0xa980dbc)
    at sp_head.cc:1520
#14 0x081f3642 in mysql_execute_command (thd=0xa9808e8) at sql_parse.cc:4385
#15 0x081f5054 in mysql_parse (thd=0xa9808e8, inBuf=0xa9af480 "CALL test.p1()", length=14)
    at sql_parse.cc:5719
#16 0x081f561d in dispatch_command (command=COM_QUERY, thd=0xa9808e8, packet=Variable "packet" is not available.
)
#17 0x081f73a7 in handle_one_connection (arg=0xa9808e8) at sql_parse.cc:1536
#18 0x00a25b80 in start_thread () from /lib/libpthread.so.0
#19 0x0097d9ce in clone () from /lib/libc.so.6

How to repeat:
# Begin clean up test section
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
delimiter |;
CREATE PROCEDURE test.p1()
BEGIN
  CREATE TABLE IF NOT EXISTS test.t1(a INT,PRIMARY KEY(a));
  CREATE TABLE IF NOT EXISTS test.t2(a INT,PRIMARY KEY(a));
  INSERT INTO test.t1 VALUES (4),(2),(1),(3);
  UPDATE test.t1 SET a=a+4 WHERE a=4;
  INSERT INTO test.t2 (a) SELECT t1.a FROM test.t1;
  UPDATE test.t1 SET a=a+4 WHERE a=8;
END|
CREATE PROCEDURE test.p2()
BEGIN
  DROP TABLE IF EXISTS test.t1;
  DROP TABLE IF EXISTS test.t2;
END|
delimiter ;|

CALL test.p1();
CALL test.p2();
CALL test.p1();

DROP TABLE t2;
DROP TABLE t3;
DROP TABLE t1;
[16 Feb 2006 2:06] Jonathan Miller
Running the test today produced this error message, thought I would add:

rpl_sp004                      [ fail ]

Errors are (from /home/ndbdev/jmiller/clones/mysql-5.1-new/mysql-test/var/log/mysqltest-time) :
mysqltest: At line 68: query 'CALL test.p1()' failed: 1477: Too many partitions were defined
(the last lines may be the most important ones)
[16 Feb 2006 18:57] Jim Winstead
This is just another manifestation of Bug #14526. (Just using a stored procedure instead of a prepared statement.)

Stripped-down test case:

delimiter |;
CREATE PROCEDURE p1()
BEGIN
  CREATE TABLE t1(a INT, PRIMARY KEY(a)) PARTITION BY KEY();
END|
delimiter ;|

CALL p1();
DROP TABLE t1;
CALL p1();
DROP TABLE t1;
[16 Feb 2006 19:21] Jim Winstead
This is actually a duplicate of Bug #14350. I moved the comments that were made against the wrong bug to that one.