summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2022-02-03 12:44:09 +0100
committerSergei Golubchik <serg@mariadb.org>2022-02-03 15:28:12 +0100
commitc0f5fd27549c84607defa64c5b651343dd29e0ee (patch)
tree6700e0fe97cb18ccc4ac6b81f33671d312cf2cea
parenta450d58ad0fb9d418b2f999938e0355616aff175 (diff)
downloadmariadb-git-bb-10.2-MDEV-277400.tar.gz
MDEV-27683 EXCHANGE PARTITION allows different index direction, but causes further errorsbb-10.2-MDEV-277400
-rw-r--r--mysql-test/main/partition_exchange.result11
-rw-r--r--mysql-test/main/partition_exchange.test13
-rw-r--r--sql/sql_table.cc3
3 files changed, 26 insertions, 1 deletions
diff --git a/mysql-test/main/partition_exchange.result b/mysql-test/main/partition_exchange.result
index 297928478bf..2b69e2fff43 100644
--- a/mysql-test/main/partition_exchange.result
+++ b/mysql-test/main/partition_exchange.result
@@ -1239,3 +1239,14 @@ DROP TABLE t1, t2;
#
# End of 10.3 tests
#
+#
+# MDEV-27683 EXCHANGE PARTITION allows different index direction, but causes further errors
+#
+CREATE TABLE t1 (a INT, KEY(a DESC)) PARTITION BY KEY(a) PARTITIONS 4;
+CREATE TABLE t2 (a INT, KEY(a));
+ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
+ERROR HY000: Tables have different definitions
+DROP TABLE t1, t2;
+#
+# End of 10.8 tests
+#
diff --git a/mysql-test/main/partition_exchange.test b/mysql-test/main/partition_exchange.test
index 7e4addebe2f..3383ebb01e3 100644
--- a/mysql-test/main/partition_exchange.test
+++ b/mysql-test/main/partition_exchange.test
@@ -535,3 +535,16 @@ DROP TABLE t1, t2;
--echo #
--echo # End of 10.3 tests
--echo #
+
+--echo #
+--echo # MDEV-27683 EXCHANGE PARTITION allows different index direction, but causes further errors
+--echo #
+CREATE TABLE t1 (a INT, KEY(a DESC)) PARTITION BY KEY(a) PARTITIONS 4;
+CREATE TABLE t2 (a INT, KEY(a));
+--error ER_TABLES_DIFFERENT_METADATA
+ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
+DROP TABLE t1, t2;
+
+--echo #
+--echo # End of 10.8 tests
+--echo #
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index cac220d1cfd..9415e6f1bd8 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -7147,7 +7147,8 @@ bool mysql_compare_tables(TABLE *table, Alter_info *alter_info,
are equal. Comparing field numbers is sufficient.
*/
if ((table_part->length != new_part->length) ||
- (table_part->fieldnr - 1 != new_part->fieldnr))
+ (table_part->fieldnr - 1 != new_part->fieldnr) ||
+ ((table_part->key_part_flag ^ new_part->key_part_flag) & HA_REVERSE_SORT))
DBUG_RETURN(false);
}
}