2010-03-17 15:10:41 +01:00
|
|
|
#
|
2010-08-16 14:53:30 +02:00
|
|
|
# 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
|
2016-03-25 20:51:22 +04:00
|
|
|
connect con1, localhost, root,,;
|
2010-08-16 14:53:30 +02:00
|
|
|
ALTER TABLE t1 TRUNCATE PARTITION pMax;
|
2016-03-25 20:51:22 +04:00
|
|
|
connection default;
|
2010-08-16 14:53:30 +02:00
|
|
|
SELECT * FROM t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
21
|
|
|
|
33
|
|
|
|
# Commit will allow the TRUNCATE to finish
|
|
|
|
COMMIT;
|
2016-03-25 20:51:22 +04:00
|
|
|
connection con1;
|
|
|
|
disconnect con1;
|
|
|
|
connection default;
|
2010-08-16 14:53:30 +02:00
|
|
|
SELECT * FROM t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
DROP TABLE t1;
|
|
|
|
#
|
2010-03-17 15:10:41 +01:00
|
|
|
# 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
|
2015-11-20 13:11:35 +01:00
|
|
|
PARTITION BY RANGE (a)
|
|
|
|
(PARTITION p0 VALUES LESS THAN MAXVALUE ENGINE = InnoDB)
|
2010-03-17 15:10:41 +01:00
|
|
|
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';
|
2015-04-07 09:56:28 +05:30
|
|
|
SELECT TABLE_SCHEMA, TABLE_NAME, PARTITION_NAME, PARTITION_ORDINAL_POSITION,
|
|
|
|
PARTITION_DESCRIPTION, TABLE_ROWS
|
|
|
|
FROM INFORMATION_SCHEMA.PARTITIONS
|
|
|
|
WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test';
|
2016-03-25 20:51:22 +04:00
|
|
|
connect con1, localhost, root,,;
|
2010-03-17 15:10:41 +01:00
|
|
|
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
|
2016-03-25 20:51:22 +04:00
|
|
|
disconnect con1;
|
|
|
|
connection default;
|
2015-04-07 09:56:28 +05:30
|
|
|
TABLE_SCHEMA TABLE_NAME PARTITION_NAME PARTITION_ORDINAL_POSITION PARTITION_DESCRIPTION TABLE_ROWS
|
|
|
|
test t1 p0 1 10 1
|
|
|
|
test t1 p10 2 MAXVALUE 3
|
2010-03-17 15:10:41 +01:00
|
|
|
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
|
2015-11-20 13:11:35 +01:00
|
|
|
PARTITION BY RANGE (a)
|
2010-03-17 15:10:41 +01:00
|
|
|
(PARTITION p0 VALUES LESS THAN (10) ENGINE = InnoDB,
|
2015-11-20 13:11:35 +01:00
|
|
|
PARTITION p10 VALUES LESS THAN MAXVALUE ENGINE = InnoDB)
|
2010-03-17 15:10:41 +01:00
|
|
|
SELECT * FROM t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
11
|
|
|
|
21
|
|
|
|
33
|
|
|
|
drop table t1;
|
|
|
|
SET DEBUG_SYNC = 'RESET';
|