1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-23357 Server crashes in Sql_cmd_alter_table_exchange_partition::exchange_partition

This commit is contained in:
Sergei Golubchik
2020-07-31 17:11:17 +02:00
parent c69520c9df
commit a0518ed998
3 changed files with 21 additions and 3 deletions

View File

@ -21,3 +21,10 @@ set @@session.alter_algorithm= @save_alter_algorithm;
CREATE TABLE t1 (a INT) PARTITION BY RANGE(a) SUBPARTITION BY HASH(a) (PARTITION p VALUES LESS THAN (5) (SUBPARTITION sp, SUBPARTITION sp1), PARTITION p1 VALUES LESS THAN MAXVALUE (SUBPARTITION sp2, SUBPARTITION sp3));
ALTER TABLE t1 DROP PARTITION p;
DROP TABLE if exists t1;
CREATE TABLE t1 (i INT);
CREATE VIEW v1 as SELECT * FROM t1;
CREATE TABLE t2 (i INT);
ALTER TABLE v1 EXCHANGE PARTITION p2 WITH TABLE t2 ;
ERROR 42000: Can't open table
DROP VIEW v1;
DROP TABLE t1, t2;

View File

@ -27,3 +27,14 @@ set @@session.alter_algorithm= @save_alter_algorithm;
CREATE TABLE t1 (a INT) PARTITION BY RANGE(a) SUBPARTITION BY HASH(a) (PARTITION p VALUES LESS THAN (5) (SUBPARTITION sp, SUBPARTITION sp1), PARTITION p1 VALUES LESS THAN MAXVALUE (SUBPARTITION sp2, SUBPARTITION sp3));
ALTER TABLE t1 DROP PARTITION p;
DROP TABLE if exists t1;
#
# MDEV-23357 Server crashes in Sql_cmd_alter_table_exchange_partition::exchange_partition
#
CREATE TABLE t1 (i INT);
CREATE VIEW v1 as SELECT * FROM t1;
CREATE TABLE t2 (i INT);
--error ER_CHECK_NO_SUCH_TABLE
ALTER TABLE v1 EXCHANGE PARTITION p2 WITH TABLE t2 ;
DROP VIEW v1;
DROP TABLE t1, t2;

View File

@ -563,12 +563,12 @@ bool Sql_cmd_alter_table_exchange_partition::
part_table= table_list->table;
swap_table= swap_table_list->table;
if (part_table->file->check_if_updates_are_ignored("ALTER"))
DBUG_RETURN(return_with_logging(thd));
if (unlikely(check_exchange_partition(swap_table, part_table)))
DBUG_RETURN(TRUE);
if (part_table->file->check_if_updates_are_ignored("ALTER"))
DBUG_RETURN(return_with_logging(thd));
/* Add IF EXISTS to binlog if shared table */
if (part_table->file->partition_ht()->flags &
HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE)