mirror of
https://github.com/MariaDB/server.git
synced 2025-01-28 17:54:16 +01:00
MDEV-5798: Wrong errorcode for missing partition after TRUNCATE PARTITION
The partitioning error handling code was looking at thd->lex->alter_info.partition_flags in non-alter-table cases, in which cases the value is stale and contains whatever was set by any earlier ALTER TABLE. This could cause the wrong error code to be generated, which then in some cases can cause replication to break with "different errorcode" error. Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
This commit is contained in:
parent
5a3a16154f
commit
b4fde50b1f
7 changed files with 116 additions and 1 deletions
|
@ -95,6 +95,33 @@ SELECT * FROM test.regular_tbl ORDER BY fkid LIMIT 2;
|
|||
--replace_column 2 date-time 3 USER 4 UUID
|
||||
SELECT * FROM test.regular_tbl ORDER BY fkid DESC LIMIT 2;
|
||||
|
||||
|
||||
--echo *** MDEV-5798: Wrong errorcode for missing partition after TRUNCATE PARTITION
|
||||
--connection master
|
||||
eval CREATE TABLE t1 (a INT)
|
||||
ENGINE=$engine_type
|
||||
PARTITION BY LIST(a) (
|
||||
PARTITION p0 VALUES IN (9, NULL),
|
||||
PARTITION p1 VALUES IN (8, 2, 7),
|
||||
PARTITION p2 VALUES IN (6, 4, 5),
|
||||
PARTITION p3 VALUES IN (3, 1, 0)
|
||||
);
|
||||
ALTER TABLE t1 DROP PARTITION p0;
|
||||
|
||||
# This failed statement leaves ALTER_PARTITION_TRUNCATE set in
|
||||
# thd->lex->alter_info.partition_flags
|
||||
--error ER_NO_SUCH_TABLE
|
||||
ALTER TABLE non_existent TRUNCATE PARTITION p1,p2;
|
||||
|
||||
# The bug was that the code would wrongly look at the (now stale) value of
|
||||
# thd->lex->alter_info.partition_flags and give the wrong error code
|
||||
# ER_WRONG_PARTITION_NAME.
|
||||
--error ER_NO_PARTITION_FOR_GIVEN_VALUE
|
||||
INSERT INTO t1 PARTITION (p1,p2,p3) VALUES (0),(9);
|
||||
|
||||
--sync_slave_with_master
|
||||
|
||||
|
||||
###### CLEAN UP SECTION ##############
|
||||
|
||||
connection master;
|
||||
|
@ -102,3 +129,4 @@ DROP PROCEDURE test.proc_norm;
|
|||
DROP PROCEDURE test.proc_byrange;
|
||||
DROP TABLE test.regular_tbl;
|
||||
DROP TABLE test.byrange_tbl;
|
||||
DROP TABLE test.t1;
|
||||
|
|
|
@ -140,8 +140,26 @@ SELECT * FROM test.regular_tbl ORDER BY fkid DESC LIMIT 2;
|
|||
id dt user uuidf fkid filler
|
||||
1 date-time USER UUID 300 Partitioned table! Going to test replication for MySQL
|
||||
2 date-time USER UUID 299 Partitioned table! Going to test replication for MySQL
|
||||
*** MDEV-5798: Wrong errorcode for missing partition after TRUNCATE PARTITION
|
||||
connection master;
|
||||
CREATE TABLE t1 (a INT)
|
||||
ENGINE='Archive'
|
||||
PARTITION BY LIST(a) (
|
||||
PARTITION p0 VALUES IN (9, NULL),
|
||||
PARTITION p1 VALUES IN (8, 2, 7),
|
||||
PARTITION p2 VALUES IN (6, 4, 5),
|
||||
PARTITION p3 VALUES IN (3, 1, 0)
|
||||
);
|
||||
ALTER TABLE t1 DROP PARTITION p0;
|
||||
ALTER TABLE non_existent TRUNCATE PARTITION p1,p2;
|
||||
ERROR 42S02: Table 'test.non_existent' doesn't exist
|
||||
INSERT INTO t1 PARTITION (p1,p2,p3) VALUES (0),(9);
|
||||
ERROR HY000: Table has no partition for value 9
|
||||
connection slave;
|
||||
connection master;
|
||||
DROP PROCEDURE test.proc_norm;
|
||||
DROP PROCEDURE test.proc_byrange;
|
||||
DROP TABLE test.regular_tbl;
|
||||
DROP TABLE test.byrange_tbl;
|
||||
DROP TABLE test.t1;
|
||||
include/rpl_end.inc
|
||||
|
|
|
@ -142,9 +142,26 @@ SELECT * FROM test.regular_tbl ORDER BY fkid DESC LIMIT 2;
|
|||
id dt user uuidf fkid filler
|
||||
1 date-time USER UUID 300 Partitioned table! Going to test replication for MySQL
|
||||
2 date-time USER UUID 299 Partitioned table! Going to test replication for MySQL
|
||||
*** MDEV-5798: Wrong errorcode for missing partition after TRUNCATE PARTITION
|
||||
connection master;
|
||||
CREATE TABLE t1 (a INT)
|
||||
ENGINE='InnoDB'
|
||||
PARTITION BY LIST(a) (
|
||||
PARTITION p0 VALUES IN (9, NULL),
|
||||
PARTITION p1 VALUES IN (8, 2, 7),
|
||||
PARTITION p2 VALUES IN (6, 4, 5),
|
||||
PARTITION p3 VALUES IN (3, 1, 0)
|
||||
);
|
||||
ALTER TABLE t1 DROP PARTITION p0;
|
||||
ALTER TABLE non_existent TRUNCATE PARTITION p1,p2;
|
||||
ERROR 42S02: Table 'test.non_existent' doesn't exist
|
||||
INSERT INTO t1 PARTITION (p1,p2,p3) VALUES (0),(9);
|
||||
ERROR HY000: Table has no partition for value 9
|
||||
connection slave;
|
||||
connection master;
|
||||
DROP PROCEDURE test.proc_norm;
|
||||
DROP PROCEDURE test.proc_byrange;
|
||||
DROP TABLE test.regular_tbl;
|
||||
DROP TABLE test.byrange_tbl;
|
||||
DROP TABLE test.t1;
|
||||
include/rpl_end.inc
|
||||
|
|
|
@ -142,9 +142,26 @@ SELECT * FROM test.regular_tbl ORDER BY fkid DESC LIMIT 2;
|
|||
id dt user uuidf fkid filler
|
||||
1 date-time USER UUID 300 Partitioned table! Going to test replication for MySQL
|
||||
2 date-time USER UUID 299 Partitioned table! Going to test replication for MySQL
|
||||
*** MDEV-5798: Wrong errorcode for missing partition after TRUNCATE PARTITION
|
||||
connection master;
|
||||
CREATE TABLE t1 (a INT)
|
||||
ENGINE='Memory'
|
||||
PARTITION BY LIST(a) (
|
||||
PARTITION p0 VALUES IN (9, NULL),
|
||||
PARTITION p1 VALUES IN (8, 2, 7),
|
||||
PARTITION p2 VALUES IN (6, 4, 5),
|
||||
PARTITION p3 VALUES IN (3, 1, 0)
|
||||
);
|
||||
ALTER TABLE t1 DROP PARTITION p0;
|
||||
ALTER TABLE non_existent TRUNCATE PARTITION p1,p2;
|
||||
ERROR 42S02: Table 'test.non_existent' doesn't exist
|
||||
INSERT INTO t1 PARTITION (p1,p2,p3) VALUES (0),(9);
|
||||
ERROR HY000: Table has no partition for value 9
|
||||
connection slave;
|
||||
connection master;
|
||||
DROP PROCEDURE test.proc_norm;
|
||||
DROP PROCEDURE test.proc_byrange;
|
||||
DROP TABLE test.regular_tbl;
|
||||
DROP TABLE test.byrange_tbl;
|
||||
DROP TABLE test.t1;
|
||||
include/rpl_end.inc
|
||||
|
|
|
@ -142,9 +142,26 @@ SELECT * FROM test.regular_tbl ORDER BY fkid DESC LIMIT 2;
|
|||
id dt user uuidf fkid filler
|
||||
1 date-time USER UUID 300 Partitioned table! Going to test replication for MySQL
|
||||
2 date-time USER UUID 299 Partitioned table! Going to test replication for MySQL
|
||||
*** MDEV-5798: Wrong errorcode for missing partition after TRUNCATE PARTITION
|
||||
connection master;
|
||||
CREATE TABLE t1 (a INT)
|
||||
ENGINE='MyISAM'
|
||||
PARTITION BY LIST(a) (
|
||||
PARTITION p0 VALUES IN (9, NULL),
|
||||
PARTITION p1 VALUES IN (8, 2, 7),
|
||||
PARTITION p2 VALUES IN (6, 4, 5),
|
||||
PARTITION p3 VALUES IN (3, 1, 0)
|
||||
);
|
||||
ALTER TABLE t1 DROP PARTITION p0;
|
||||
ALTER TABLE non_existent TRUNCATE PARTITION p1,p2;
|
||||
ERROR 42S02: Table 'test.non_existent' doesn't exist
|
||||
INSERT INTO t1 PARTITION (p1,p2,p3) VALUES (0),(9);
|
||||
ERROR HY000: Table has no partition for value 9
|
||||
connection slave;
|
||||
connection master;
|
||||
DROP PROCEDURE test.proc_norm;
|
||||
DROP PROCEDURE test.proc_byrange;
|
||||
DROP TABLE test.regular_tbl;
|
||||
DROP TABLE test.byrange_tbl;
|
||||
DROP TABLE test.t1;
|
||||
include/rpl_end.inc
|
||||
|
|
|
@ -10143,7 +10143,8 @@ void ha_partition::print_error(int error, myf errflag)
|
|||
|
||||
/* Should probably look for my own errors first */
|
||||
if ((error == HA_ERR_NO_PARTITION_FOUND) &&
|
||||
! (thd->lex->alter_info.partition_flags & ALTER_PARTITION_TRUNCATE))
|
||||
! (thd->lex->sql_command == SQLCOM_ALTER_TABLE &&
|
||||
(thd->lex->alter_info.partition_flags & ALTER_PARTITION_TRUNCATE)))
|
||||
{
|
||||
m_part_info->print_no_partition_found(table, errflag);
|
||||
DBUG_VOID_RETURN;
|
||||
|
|
|
@ -142,9 +142,26 @@ SELECT * FROM test.regular_tbl ORDER BY fkid DESC LIMIT 2;
|
|||
id dt user uuidf fkid filler
|
||||
1 date-time USER UUID 300 Partitioned table! Going to test replication for MySQL
|
||||
2 date-time USER UUID 299 Partitioned table! Going to test replication for MySQL
|
||||
*** MDEV-5798: Wrong errorcode for missing partition after TRUNCATE PARTITION
|
||||
connection master;
|
||||
CREATE TABLE t1 (a INT)
|
||||
ENGINE=TokuDB;
|
||||
PARTITION BY LIST(a) (
|
||||
PARTITION p0 VALUES IN (9, NULL),
|
||||
PARTITION p1 VALUES IN (8, 2, 7),
|
||||
PARTITION p2 VALUES IN (6, 4, 5),
|
||||
PARTITION p3 VALUES IN (3, 1, 0)
|
||||
);
|
||||
ALTER TABLE t1 DROP PARTITION p0;
|
||||
ALTER TABLE non_existent TRUNCATE PARTITION p1,p2;
|
||||
ERROR 42S02: Table 'test.non_existent' doesn't exist
|
||||
INSERT INTO t1 PARTITION (p1,p2,p3) VALUES (0),(9);
|
||||
ERROR HY000: Table has no partition for value 9
|
||||
connection slave;
|
||||
connection master;
|
||||
DROP PROCEDURE test.proc_norm;
|
||||
DROP PROCEDURE test.proc_byrange;
|
||||
DROP TABLE test.regular_tbl;
|
||||
DROP TABLE test.byrange_tbl;
|
||||
DROP TABLE test.t1;
|
||||
include/rpl_end.inc
|
||||
|
|
Loading…
Add table
Reference in a new issue