summaryrefslogtreecommitdiff
path: root/sql/sql_partition_admin.cc
diff options
context:
space:
mode:
authorMasashi Tomooka <tmokmss@users.noreply.github.com>2022-05-30 19:28:44 +0900
committerGitHub <noreply@github.com>2022-05-30 19:28:44 +0900
commitf7137a619f8518edb7eab096e59e3c825046eaeb (patch)
tree42f4a9b30e70efc5a733e11a6a7359a5e4acf60c /sql/sql_partition_admin.cc
parentc4e87cb22cd78b5539202d9dcf13954375decb67 (diff)
downloadmariadb-git-f7137a619f8518edb7eab096e59e3c825046eaeb.tar.gz
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
Diffstat (limited to 'sql/sql_partition_admin.cc')
-rw-r--r--sql/sql_partition_admin.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc
index cec7ecc6806..90b114b792c 100644
--- a/sql/sql_partition_admin.cc
+++ b/sql/sql_partition_admin.cc
@@ -539,6 +539,14 @@ bool Sql_cmd_alter_table_exchange_partition::
part_table= 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)))
DBUG_RETURN(TRUE);