mirror of
https://github.com/zebrajr/server.git
synced 2025-12-06 12:20:40 +01:00
MDEV-20131 Assertion `!pk->has_virtual ()' failed in instant_alter_column_possible
Problem:- Primary key on long unique columns is not allowed but when `CREATE TABLE t2 (a TEXT, PRIMARY KEY(a(1871))) ENGINE=InnoDB;` is executed with innodb_page_size=8k or 4k, primary key on DB_ROW_HASH_1 column is created. Reason of this is in mysql_prepare_create_table we check against max_key_part_length() to see whether key_part length is more then engine supported key_part length , and if it is true error is thrown for primary key and long unique index is created for unique key. But in this case max_key_part_length() returns 3072 which is more the max_key_length() , which later in code triggers creating of long unique index. Solution:- max_supported_key_part_length() should return according to innodb page size.
This commit is contained in:
parent
8a2b4d531d
commit
b1881e0779
1
mysql-test/main/long_unique_bugs.opt
Normal file
1
mysql-test/main/long_unique_bugs.opt
Normal file
|
|
@ -0,0 +1 @@
|
|||
--innodb-page-size=8K
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -6537,14 +6537,21 @@ ha_innobase::clone(
|
|||
DBUG_RETURN(new_handler);
|
||||
}
|
||||
|
||||
|
||||
uint
|
||||
ha_innobase::max_supported_key_part_length() const
|
||||
/*==============================================*/
|
||||
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);
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************//**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user