mirror of
https://github.com/MariaDB/server.git
synced 2025-10-15 11:08:40 +03:00
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.
96 lines
2.9 KiB
Plaintext
96 lines
2.9 KiB
Plaintext
#
|
|
# 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)
|
|
engine = innodb
|
|
partition by range (a)
|
|
(partition p0 values less than MAXVALUE);
|
|
insert into t1 values (1), (11), (21), (33);
|
|
SELECT * FROM t1;
|
|
a
|
|
1
|
|
11
|
|
21
|
|
33
|
|
SHOW CREATE TABLE t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`a` int(11) DEFAULT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
/*!50100 PARTITION BY RANGE (a)
|
|
(PARTITION p0 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
|
|
t1#P#p0.ibd
|
|
t1.frm
|
|
t1.par
|
|
SET DEBUG_SYNC='before_open_in_get_all_tables SIGNAL parked WAIT_FOR open';
|
|
SET DEBUG_SYNC='partition_open_error SIGNAL alter WAIT_FOR finish';
|
|
SELECT * FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test';
|
|
SET DEBUG_SYNC = 'now WAIT_FOR parked';
|
|
# When waiting for the name lock in get_all_tables in sql_show.cc
|
|
# this will not be concurrent any more, thus the TIMEOUT
|
|
SET DEBUG_SYNC = 'before_rename_partitions SIGNAL open WAIT_FOR alter TIMEOUT 1';
|
|
# Needs to be executed twice, since first is this 'SET DEBUG_SYNC ...'
|
|
SET DEBUG_SYNC = 'before_close_thread_tables SIGNAL finish EXECUTE 2';
|
|
ALTER TABLE t1 REORGANIZE PARTITION p0 INTO
|
|
(PARTITION p0 VALUES LESS THAN (10),
|
|
PARTITION p10 VALUES LESS THAN MAXVALUE);
|
|
Warnings:
|
|
Warning 1639 debug sync point wait timed out
|
|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME
|
|
def test t1 p0 NULL 1 NULL RANGE NULL a NULL 10 1 16384 16384 NULL 0 0 NULL NULL NULL NULL default NULL
|
|
def test t1 p10 NULL 2 NULL RANGE NULL a NULL MAXVALUE 3 5461 16384 NULL 0 0 NULL NULL NULL NULL default NULL
|
|
t1#P#p0.ibd
|
|
t1#P#p10.ibd
|
|
t1.frm
|
|
t1.par
|
|
SHOW CREATE TABLE t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`a` int(11) DEFAULT NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
/*!50100 PARTITION BY RANGE (a)
|
|
(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
|
|
PARTITION p10 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
|
|
SELECT * FROM t1;
|
|
a
|
|
1
|
|
11
|
|
21
|
|
33
|
|
drop table t1;
|
|
SET DEBUG_SYNC = 'RESET';
|