1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Fixed MDEV-365 "Got assertion when doing alter table on a partition"

mysql-test/r/partition.result:
  Added test case
mysql-test/t/partition.test:
  Added test case
sql/sql_partition.cc:
  Do mysql_trans_prepare_alter_copy_data() after all original tables are locked.
  (We don't want to disable transactions for the original tables, that still may be in the cache)
sql/sql_table.cc:
  Fixed two wrong DBUG_ENTER
This commit is contained in:
Michael Widenius
2012-08-15 13:33:37 +03:00
parent 9c1cc61caf
commit fbe5ac4e24
4 changed files with 30 additions and 4 deletions

View File

@@ -2473,3 +2473,17 @@ SELECT * FROM vtmp;
1
DROP VIEW vtmp;
DROP TABLE t1;
#
# MDEV-365 "Got assertion when doing alter table on a partition"
#
CREATE TABLE t1 ( i INT ) ENGINE=Aria PARTITION BY HASH(i) PARTITIONS 2;
INSERT INTO t1 VALUES (1),(2),(2),(3),(4);
ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
SELECT * from t1 order by i;
i
1
2
2
3
4
DROP TABLE t1;

View File

@@ -2476,3 +2476,13 @@ SELECT 1 FROM t1 AS t1_0 JOIN t1 ON t1_0.a LIKE (SELECT 1 FROM t1);
SELECT * FROM vtmp;
DROP VIEW vtmp;
DROP TABLE t1;
--echo #
--echo # MDEV-365 "Got assertion when doing alter table on a partition"
--echo #
CREATE TABLE t1 ( i INT ) ENGINE=Aria PARTITION BY HASH(i) PARTITIONS 2;
INSERT INTO t1 VALUES (1),(2),(2),(3),(4);
ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
SELECT * from t1 order by i;
DROP TABLE t1;

View File

@@ -5500,10 +5500,12 @@ static bool mysql_change_partitions(ALTER_PARTITION_PARAM_TYPE *lpt)
build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0);
if(mysql_trans_prepare_alter_copy_data(thd))
/* First lock the original tables */
if (file->ha_external_lock(thd, F_WRLCK))
DBUG_RETURN(TRUE);
if (file->ha_external_lock(thd, F_WRLCK))
/* Disable transactions for all new tables */
if (mysql_trans_prepare_alter_copy_data(thd))
DBUG_RETURN(TRUE);
/* TODO: test if bulk_insert would increase the performance */

View File

@@ -7247,7 +7247,7 @@ err_with_mdl:
bool mysql_trans_prepare_alter_copy_data(THD *thd)
{
DBUG_ENTER("mysql_prepare_alter_copy_data");
DBUG_ENTER("mysql_trans_prepare_alter_copy_data");
/*
Turn off recovery logging since rollback of an alter table is to
delete the new table so there is no need to log the changes to it.
@@ -7267,7 +7267,7 @@ bool mysql_trans_prepare_alter_copy_data(THD *thd)
bool mysql_trans_commit_alter_copy_data(THD *thd)
{
bool error= FALSE;
DBUG_ENTER("mysql_commit_alter_copy_data");
DBUG_ENTER("mysql_trans_commit_alter_copy_data");
if (ha_enable_transaction(thd, TRUE))
DBUG_RETURN(TRUE);