Commit a68742f4 authored by holyfoot@vva.(none)'s avatar holyfoot@vva.(none)

bug #17290 (sp with delete, create and rollback causes MySQLD core)

additional fixes
parent 87a4e300
...@@ -557,4 +557,29 @@ t2 CREATE TABLE `t2` ( ...@@ -557,4 +557,29 @@ t2 CREATE TABLE `t2` (
PRIMARY KEY (`a`) PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='no comment' PARTITION BY KEY (a) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='no comment' PARTITION BY KEY (a)
drop table t2; drop table t2;
prepare stmt1 from 'create table t1 (s1 int) partition by hash (s1)';
execute stmt1;
execute stmt1;
ERROR 42S01: Table 't1' already exists
drop table t1;
CREATE PROCEDURE test.p1(IN i INT)
BEGIN
DECLARE CONTINUE HANDLER FOR sqlexception BEGIN END;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (num INT,PRIMARY KEY(num));
START TRANSACTION;
INSERT INTO t1 VALUES(i);
savepoint t1_save;
INSERT INTO t1 VALUES (14);
ROLLBACK to savepoint t1_save;
COMMIT;
END|
CALL test.p1(12);
Warnings:
Note 1051 Unknown table 't1'
Warning 1196 Some non-transactional changed tables couldn't be rolled back
CALL test.p1(13);
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
drop table t1;
End of 5.1 tests End of 5.1 tests
...@@ -714,4 +714,34 @@ show create table t2; ...@@ -714,4 +714,34 @@ show create table t2;
drop table t2; drop table t2;
#
# bug #14350 Partitions: crash if prepared statement
#
prepare stmt1 from 'create table t1 (s1 int) partition by hash (s1)';
execute stmt1;
--error 1050
execute stmt1;
drop table t1;
#
# bug 17290 SP with delete, create and rollback to save point causes MySQLD core
#
delimiter |;
eval CREATE PROCEDURE test.p1(IN i INT)
BEGIN
DECLARE CONTINUE HANDLER FOR sqlexception BEGIN END;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (num INT,PRIMARY KEY(num));
START TRANSACTION;
INSERT INTO t1 VALUES(i);
savepoint t1_save;
INSERT INTO t1 VALUES (14);
ROLLBACK to savepoint t1_save;
COMMIT;
END|
delimiter ;|
CALL test.p1(12);
CALL test.p1(13);
drop table t1;
--echo End of 5.1 tests --echo End of 5.1 tests
...@@ -2357,6 +2357,7 @@ mysql_execute_command(THD *thd) ...@@ -2357,6 +2357,7 @@ mysql_execute_command(THD *thd)
/* Saved variable value */ /* Saved variable value */
DBUG_ENTER("mysql_execute_command"); DBUG_ENTER("mysql_execute_command");
thd->net.no_send_error= 0; thd->net.no_send_error= 0;
thd->work_part_info= 0;
/* /*
In many cases first table of main SELECT_LEX have special meaning => In many cases first table of main SELECT_LEX have special meaning =>
...@@ -2902,6 +2903,15 @@ mysql_execute_command(THD *thd) ...@@ -2902,6 +2903,15 @@ mysql_execute_command(THD *thd)
lex->like_name); lex->like_name);
else else
{ {
#ifdef WITH_PARTITION_STORAGE_ENGINE
partition_info *part_info= thd->lex->part_info;
if (part_info && !(part_info= thd->lex->part_info->get_clone()))
{
res= -1;
goto end_with_restore_list;
}
thd->work_part_info= part_info;
#endif
res= mysql_create_table(thd, create_table->db, res= mysql_create_table(thd, create_table->db,
create_table->table_name, &lex->create_info, create_table->table_name, &lex->create_info,
lex->create_list, lex->create_list,
......
...@@ -3760,7 +3760,7 @@ bool mysql_unpack_partition(THD *thd, const uchar *part_buf, ...@@ -3760,7 +3760,7 @@ bool mysql_unpack_partition(THD *thd, const uchar *part_buf,
} }
} }
else else
part_info= old_lex->part_info; part_info= thd->work_part_info;
} }
table->part_info= part_info; table->part_info= part_info;
table->file->set_part_info(part_info); table->file->set_part_info(part_info);
...@@ -4077,7 +4077,9 @@ uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info, ...@@ -4077,7 +4077,9 @@ uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info,
if (table->part_info) if (table->part_info)
table->s->version= 0L; table->s->version= 0L;
if (!(thd->work_part_info= thd->lex->part_info->get_clone())) thd->work_part_info= thd->lex->part_info;
if (thd->work_part_info &&
!(thd->work_part_info= thd->lex->part_info->get_clone()))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (alter_info->flags & if (alter_info->flags &
......
...@@ -2037,10 +2037,8 @@ bool mysql_create_table_internal(THD *thd, ...@@ -2037,10 +2037,8 @@ bool mysql_create_table_internal(THD *thd,
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
#ifdef WITH_PARTITION_STORAGE_ENGINE #ifdef WITH_PARTITION_STORAGE_ENGINE
partition_info *part_info; partition_info *part_info= thd->work_part_info;
if (!(part_info= thd->lex->part_info->get_clone()))
DBUG_RETURN(TRUE);
thd->work_part_info= part_info;
if (!part_info && create_info->db_type->partition_flags && if (!part_info && create_info->db_type->partition_flags &&
(create_info->db_type->partition_flags() & HA_USE_AUTO_PARTITION)) (create_info->db_type->partition_flags() & HA_USE_AUTO_PARTITION))
{ {
...@@ -2089,7 +2087,8 @@ bool mysql_create_table_internal(THD *thd, ...@@ -2089,7 +2087,8 @@ bool mysql_create_table_internal(THD *thd,
goto err; goto err;
} }
} }
if (part_engine_type == &partition_hton) if ((part_engine_type == &partition_hton) &&
part_info->default_engine_type)
{ {
/* /*
This only happens at ALTER TABLE. This only happens at ALTER TABLE.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment