summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/main/long_unique_bugs.opt1
-rw-r--r--mysql-test/main/long_unique_bugs.result4
-rw-r--r--mysql-test/main/long_unique_bugs.test6
-rw-r--r--storage/innobase/handler/ha_innodb.cc23
4 files changed, 25 insertions, 9 deletions
diff --git a/mysql-test/main/long_unique_bugs.opt b/mysql-test/main/long_unique_bugs.opt
new file mode 100644
index 00000000000..058a129cdc2
--- /dev/null
+++ b/mysql-test/main/long_unique_bugs.opt
@@ -0,0 +1 @@
+--innodb-page-size=8K
diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result
index 5d6c0562c8a..e1c5738e2aa 100644
--- a/mysql-test/main/long_unique_bugs.result
+++ b/mysql-test/main/long_unique_bugs.result
@@ -148,7 +148,7 @@ ALTER TABLE t1 DROP KEY f, ADD INDEX idx1(f), ALGORITHM=INSTANT;
ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
ALTER TABLE t1 ADD KEY idx2(f);
Warnings:
-Note 1071 Specified key was too long; max key length is 3072 bytes
+Note 1071 Specified key was too long; max key length is 1536 bytes
DROP TABLE t1;
CREATE TABLE t1(a blob , b blob , unique(a,b));
alter table t1 drop column b;
@@ -288,3 +288,5 @@ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_par
t2 0 a 1 a A NULL NULL NULL YES HASH
t2 0 a 2 b A NULL NULL NULL YES HASH
DROP TABLE t1,t2;
+CREATE TABLE t2 (a TEXT, PRIMARY KEY(a(1871))) ENGINE=InnoDB;
+ERROR 42000: Specified key was too long; max key length is 1536 bytes
diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test
index 34d02b1c8f4..b38ce881802 100644
--- a/mysql-test/main/long_unique_bugs.test
+++ b/mysql-test/main/long_unique_bugs.test
@@ -368,3 +368,9 @@ show index from t2;
# Cleanup
DROP TABLE t1,t2;
+
+#
+# MDEV-20131 Assertion `!pk->has_virtual ()' failed in instant_alter_column_possible
+# (.opt file is created which will make innodb_page_size=8k)
+--error ER_TOO_LONG_KEY
+CREATE TABLE t2 (a TEXT, PRIMARY KEY(a(1871))) ENGINE=InnoDB;
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index ce2e4b6990f..e5e864bffc5 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -6537,14 +6537,21 @@ ha_innobase::clone(
DBUG_RETURN(new_handler);
}
-
-uint
-ha_innobase::max_supported_key_part_length() const
-/*==============================================*/
-{
- /* A table format specific index column length check will be performed
- at ha_innobase::add_index() and row_create_index_for_mysql() */
- return(REC_VERSION_56_MAX_INDEX_COL_LEN);
+uint ha_innobase::max_supported_key_part_length() const
+{
+ /* A table format specific index column length check will be performed
+ at ha_innobase::add_index() and row_create_index_for_mysql() */
+ /* FIXME: rewrite this as well as ha_innobase::max_supported_key_length()
+ using an API that considers the PRIMARY KEY as well as secondary index
+ metadata and the ROW_FORMAT and KEY_BLOCK_SIZE */
+ switch (srv_page_size) {
+ case 4096:
+ return 1173;
+ case 8192:
+ return 1536;
+ default:
+ return REC_VERSION_56_MAX_INDEX_COL_LEN;
+ }
}
/******************************************************************//**