diff options
author | Mattias Jonsson <mattias.jonsson@oracle.com> | 2010-08-16 14:53:30 +0200 |
---|---|---|
committer | Mattias Jonsson <mattias.jonsson@oracle.com> | 2010-08-16 14:53:30 +0200 |
commit | 4b20ccafaa3bacfd11c5fcc61e1647dbbefe7bad (patch) | |
tree | c70fa0c8e6b1e40f9c93c89eed5cb4337b1b681c /mysql-test/suite/parts | |
parent | 0058f16d933d6de41e670348080ce625d8109b47 (diff) | |
download | mariadb-git-4b20ccafaa3bacfd11c5fcc61e1647dbbefe7bad.tar.gz |
Bug#49907: ALTER TABLE ... TRUNCATE PARTITION does not wait for
locks on the table
Fixing the partitioning specifics after TRUNCATE TABLE in
bug-42643 was fixed.
Reorganize of code to decrease the size of the giant switch
in mysql_execute_command, and to prepare for future parser
reengineering. Moved code into Sql_statement objects.
Updated patch according to davi's review comments.
libmysqld/CMakeLists.txt:
Added new files.
libmysqld/Makefile.am:
Added new files.
mysql-test/r/not_partition.result:
now returning error on partitioning commands
if partitioning is not enabled.
mysql-test/r/partition_disabled.result:
There is no partition handlerton, so it cannot
find the specified engine in the .frm file.
mysql-test/r/partition_truncate.result:
Updated test results.
mysql-test/suite/parts/inc/partition_mgm.inc:
Added check that TRUNCATE PARTITION does not delete on failure.
mysql-test/suite/parts/r/partition_debug_sync_innodb.result:
updated results.
mysql-test/suite/parts/r/partition_mgm_lc0_archive.result:
updated results.
mysql-test/suite/parts/r/partition_mgm_lc1_archive.result:
updated results.
mysql-test/suite/parts/r/partition_mgm_lc2_archive.result:
updated results.
mysql-test/suite/parts/t/partition_debug_sync_innodb.test:
Test case for this bug.
mysql-test/t/not_partition.test:
Added check for TRUNCATE PARTITION without partitioning.
mysql-test/t/partition_truncate.test:
Added test of TRUNCATE PARTITION on non partitioned table.
sql/CMakeLists.txt:
Added new files.
sql/Makefile.am:
Added new files.
sql/datadict.cc:
Moved out the storage engine check into an own
function, including assert for lock.
sql/datadict.h:
added dd_frm_storage_engine.
sql/sql_alter_table.cc:
moved the code for SQLCOM_ALTER_TABLE in mysql_execute_command
into its own file, and using the Sql_statement object to
prepare for future parser reengineering.
sql/sql_alter_table.h:
Created Sql_statement object for ALTER TABLE.
sql/sql_lex.cc:
resetting m_stmt.
sql/sql_lex.h:
Temporary hack for forward declaration of enum_alter_table_change_level.
sql/sql_parse.cc:
Moved out ALTER/ANALYZE/CHECK/OPTIMIZE/REPAIR TABLE
from the giant switch into their own Sql_statement
objects.
sql/sql_parse.h:
Exporting check_merge_table_access.
sql/sql_partition_admin.cc:
created Sql_statement for
ALTER TABLE t ANALYZE/CHECK/OPTIMIZE/REPAIR/TRUNCATE
PARTITION. To be able to reuse the TABLE equivalents.
sql/sql_partition_admin.h:
Added Sql_statement of partition admin statements.
sql/sql_table.cc:
Moved table maintenance code into sql_table_maintenance.cc
sql/sql_table.h:
Moved table maintenance code into sql_table_maintenance.h
exporting functions used by sql_table_maintenance.
sql/sql_table_maintenance.cc:
Moved table maintenance code from sql_table.cc
sql/sql_table_maintenance.h:
Sql_statement objects for ANALYZE/CHECK/OPTIMIZE/REPAIR TABLE.
Also declaring the keycache functions.
sql/sql_truncate.cc:
Moved code from SQLCOM_TRUNCATE in mysql_execute_command into
Truncate_statement::execute.
Added check for partitioned table on TRUNCATE PARTITION.
Moved locking fix for partitioned table into
Alter_table_truncate_partition::execute.
sql/sql_truncate.h:
Truncate_statement declaration (sub class of Sql_statement).
sql/sql_yacc.yy:
Using the new Sql_statment objects.
Diffstat (limited to 'mysql-test/suite/parts')
6 files changed, 107 insertions, 0 deletions
diff --git a/mysql-test/suite/parts/inc/partition_mgm.inc b/mysql-test/suite/parts/inc/partition_mgm.inc index 9dfa2b2ffb3..67d1feb8046 100644 --- a/mysql-test/suite/parts/inc/partition_mgm.inc +++ b/mysql-test/suite/parts/inc/partition_mgm.inc @@ -533,6 +533,8 @@ PARTITION BY KEY (a) INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); --error ER_PARTITION_MGMT_ON_NONPARTITIONED, ER_ILLEGAL_HA ALTER TABLE t1 TRUNCATE PARTITION MAX; +--sorted_result +SELECT * FROM t1; } if (!$no_truncate) { diff --git a/mysql-test/suite/parts/r/partition_debug_sync_innodb.result b/mysql-test/suite/parts/r/partition_debug_sync_innodb.result index 9e72259a150..268db30bda0 100644 --- a/mysql-test/suite/parts/r/partition_debug_sync_innodb.result +++ b/mysql-test/suite/parts/r/partition_debug_sync_innodb.result @@ -1,4 +1,38 @@ # +# Bug#49907: ALTER TABLE ... TRUNCATE PARTITION +# does not wait for locks on the table +# +CREATE TABLE t1 (a INT) +ENGINE = InnoDB +PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (15), +PARTITION pMax VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (1), (11), (21), (33); +BEGIN; +DELETE FROM t1 WHERE a = 11; +SELECT * FROM t1; +a +1 +21 +33 +# con1 (send) +ALTER TABLE t1 TRUNCATE PARTITION pMax; +# con default +SELECT * FROM t1; +a +1 +21 +33 +# Commit will allow the TRUNCATE to finish +COMMIT; +# con1 (reap) +# con1 (disconnect) +# default connection +SELECT * FROM t1; +a +1 +DROP TABLE t1; +# # Bug#50561: ALTER PARTITIONS does not have adequate lock, breaks with # concurrent I_S query create table t1 (a int) diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result b/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result index 4f623813386..f4d76874b4c 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result @@ -927,6 +927,16 @@ PARTITION MAX); INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); ALTER TABLE t1 TRUNCATE PARTITION MAX; Got one of the listed errors +SELECT * FROM t1; +a b +1 First +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2 Second +2000 First in MAX +2001 Second in MAX +999 Last in LT1000 # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result b/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result index 4cd8cafa3ee..1113e7dcb0c 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result @@ -894,6 +894,16 @@ PARTITION MAX); INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); ALTER TABLE t1 TRUNCATE PARTITION MAX; Got one of the listed errors +SELECT * FROM t1; +a b +1 First +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2 Second +2000 First in MAX +2001 Second in MAX +999 Last in LT1000 # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result b/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result index 6e8abfef06d..e71803fcac9 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result @@ -894,6 +894,16 @@ PARTITION MAX); INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); ALTER TABLE t1 TRUNCATE PARTITION MAX; Got one of the listed errors +SELECT * FROM t1; +a b +1 First +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2 Second +2000 First in MAX +2001 Second in MAX +999 Last in LT1000 # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/t/partition_debug_sync_innodb.test b/mysql-test/suite/parts/t/partition_debug_sync_innodb.test index 79ef3d537bf..a6db0d39925 100644 --- a/mysql-test/suite/parts/t/partition_debug_sync_innodb.test +++ b/mysql-test/suite/parts/t/partition_debug_sync_innodb.test @@ -5,6 +5,47 @@ let $MYSQLD_DATADIR=`SELECT @@datadir`; --echo # +--echo # Bug#49907: ALTER TABLE ... TRUNCATE PARTITION +--echo # does not wait for locks on the table +--echo # +CREATE TABLE t1 (a INT) +ENGINE = InnoDB +PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (15), + PARTITION pMax VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (1), (11), (21), (33); +BEGIN; +DELETE FROM t1 WHERE a = 11; +--sorted_result +SELECT * FROM t1; + +--connect (con1, localhost, root,,) +--echo # con1 (send) +--send +ALTER TABLE t1 TRUNCATE PARTITION pMax; + +--connection default +--echo # con default +let $wait_condition= + SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST + WHERE STATE = "Waiting for table" AND INFO = "ALTER TABLE t1 TRUNCATE PARTITION pMax"; +--source include/wait_condition.inc +--sorted_result +SELECT * FROM t1; +--echo # Commit will allow the TRUNCATE to finish +COMMIT; + +--echo # con1 (reap) +--connection con1 +--reap +--echo # con1 (disconnect) +--disconnect con1 +--connection default +--echo # default connection +SELECT * FROM t1; +DROP TABLE t1; + +--echo # --echo # Bug#50561: ALTER PARTITIONS does not have adequate lock, breaks with --echo # concurrent I_S query create table t1 (a int) |