1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

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.
This commit is contained in:
Mattias Jonsson
2010-08-16 14:53:30 +02:00
parent 87f655d52d
commit 25ae81f133
32 changed files with 2116 additions and 1193 deletions

View File

@@ -21,23 +21,17 @@ Table Op Msg_type Msg_text
test.t1 repair Error Unknown storage engine 'partition'
test.t1 repair error Corrupt
ALTER TABLE t1 REPAIR PARTITION ALL;
Table Op Msg_type Msg_text
test.t1 repair Error Unknown storage engine 'partition'
test.t1 repair error Corrupt
ERROR HY000: The 'partitioning' feature is disabled; you need MySQL built with '--with-plugin-partition' to have it working
ALTER TABLE t1 CHECK PARTITION ALL;
Table Op Msg_type Msg_text
test.t1 check Error Unknown storage engine 'partition'
test.t1 check error Corrupt
ERROR HY000: The 'partitioning' feature is disabled; you need MySQL built with '--with-plugin-partition' to have it working
ALTER TABLE t1 OPTIMIZE PARTITION ALL;
Table Op Msg_type Msg_text
test.t1 optimize Error Unknown storage engine 'partition'
test.t1 optimize error Corrupt
ERROR HY000: The 'partitioning' feature is disabled; you need MySQL built with '--with-plugin-partition' to have it working
ALTER TABLE t1 ANALYZE PARTITION ALL;
Table Op Msg_type Msg_text
test.t1 analyze Error Unknown storage engine 'partition'
test.t1 analyze error Corrupt
ERROR HY000: The 'partitioning' feature is disabled; you need MySQL built with '--with-plugin-partition' to have it working
ALTER TABLE t1 REBUILD PARTITION ALL;
ERROR 42000: Unknown storage engine 'partition'
ALTER TABLE t1 TRUNCATE PARTITION ALL;
ERROR HY000: The 'partitioning' feature is disabled; you need MySQL built with '--with-plugin-partition' to have it working
ALTER TABLE t1 ENGINE Memory;
ERROR 42000: Unknown storage engine 'partition'
ALTER TABLE t1 ADD (new INT);

View File

@@ -3,7 +3,7 @@ FLUSH TABLES;
SELECT * FROM t1;
ERROR HY000: The MySQL server is running with the --skip-partition option so it cannot execute this statement
TRUNCATE TABLE t1;
ERROR HY000: The MySQL server is running with the --skip-partition option so it cannot execute this statement
ERROR 42S02: Table 'test.t1' doesn't exist
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze Error The MySQL server is running with the --skip-partition option so it cannot execute this statement

View File

@@ -16,3 +16,11 @@ subpartitions 1
alter table t1 truncate partition sp1;
ERROR HY000: Incorrect partition name
drop table t1;
create table t1 (a int);
insert into t1 values (1), (3), (8);
alter table t1 truncate partition p0;
ERROR HY000: Partition management on a not partitioned table is not possible
select count(*) from t1;
count(*)
3
drop table t1;

View File

@@ -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)
{

View File

@@ -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)

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -4,6 +4,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

View File

@@ -27,6 +27,7 @@ ALTER TABLE t1 CHECK PARTITION ALL;
ALTER TABLE t1 OPTIMIZE PARTITION ALL;
ALTER TABLE t1 ANALYZE PARTITION ALL;
ALTER TABLE t1 REBUILD PARTITION ALL;
ALTER TABLE t1 TRUNCATE PARTITION ALL;
ALTER TABLE t1 ENGINE Memory;
ALTER TABLE t1 ADD (new INT);
DROP TABLE t1;

View File

@@ -24,3 +24,10 @@ subpartitions 1
--error ER_WRONG_PARTITION_NAME
alter table t1 truncate partition sp1;
drop table t1;
create table t1 (a int);
insert into t1 values (1), (3), (8);
--error ER_PARTITION_MGMT_ON_NONPARTITIONED
alter table t1 truncate partition p0;
select count(*) from t1;
drop table t1;