MDEV-28599 EXCHANGE PARTITION on view causes ER_CHECK_NO_SUCH_TABLE instead of ER_WRONG_OBJECT
ER_CHECK_NO_SUCH_TABLE was raised because a view does not have the corresponding TABLE instance connected to TABLE_LIST and the server interprets the absence as the absence of the table itself. To fix the problem, we add a check to ensure that the target table to be swapped with a partition is not a view. Reviewed by: Nayuta Yanagisawa
This commit is contained in:
parent
c4e87cb22c
commit
f7137a619f
@ -6,7 +6,18 @@ drop table if exists t1, t2;
|
|||||||
CREATE TABLE t1 (a int);
|
CREATE TABLE t1 (a int);
|
||||||
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
|
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
|
||||||
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE v1;
|
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE v1;
|
||||||
ERROR 42000: Can't open table
|
ERROR HY000: 'test.v1' is not of type 'BASE TABLE'
|
||||||
|
DROP VIEW v1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
#
|
||||||
|
# MDEV-28599 EXCHANGE PARTITION on view causes ER_CHECK_NO_SUCH_TABLE instead of ER_WRONG_OBJECT
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a int)
|
||||||
|
PARTITION BY HASH (a)
|
||||||
|
PARTITIONS 2;
|
||||||
|
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
|
||||||
|
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE v1;
|
||||||
|
ERROR HY000: 'test.v1' is not of type 'BASE TABLE'
|
||||||
DROP VIEW v1;
|
DROP VIEW v1;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
#
|
#
|
||||||
|
@ -16,7 +16,19 @@ let $MYSQLD_DATADIR= `SELECT @@datadir`;
|
|||||||
--echo #
|
--echo #
|
||||||
CREATE TABLE t1 (a int);
|
CREATE TABLE t1 (a int);
|
||||||
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
|
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
|
||||||
--error ER_CHECK_NO_SUCH_TABLE
|
--error ER_WRONG_OBJECT
|
||||||
|
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE v1;
|
||||||
|
DROP VIEW v1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-28599 EXCHANGE PARTITION on view causes ER_CHECK_NO_SUCH_TABLE instead of ER_WRONG_OBJECT
|
||||||
|
--echo #
|
||||||
|
CREATE TABLE t1 (a int)
|
||||||
|
PARTITION BY HASH (a)
|
||||||
|
PARTITIONS 2;
|
||||||
|
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
|
||||||
|
--error ER_WRONG_OBJECT
|
||||||
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE v1;
|
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE v1;
|
||||||
DROP VIEW v1;
|
DROP VIEW v1;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
@ -539,6 +539,14 @@ bool Sql_cmd_alter_table_exchange_partition::
|
|||||||
part_table= table_list->table;
|
part_table= table_list->table;
|
||||||
swap_table= swap_table_list->table;
|
swap_table= swap_table_list->table;
|
||||||
|
|
||||||
|
/* Don't allow to exchange with a VIEW */
|
||||||
|
if (unlikely(swap_table_list->view))
|
||||||
|
{
|
||||||
|
my_error(ER_WRONG_OBJECT, MYF(0), table_list->db.str,
|
||||||
|
swap_table_list->table_name.str, "BASE TABLE");
|
||||||
|
DBUG_RETURN(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
if (unlikely(check_exchange_partition(swap_table, part_table)))
|
if (unlikely(check_exchange_partition(swap_table, part_table)))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user