Re: [Maria-developers] b1881e07797: MDEV-20131 Assertion `!pk->has_virtual ()' failed in instant_alter_column_possible
Hi, Sachin! On Jul 12, Sachin Kumar wrote:
revision-id: b1881e07797 (mariadb-10.4.20-9-gb1881e07797) parent(s): 8a2b4d531dc author: Sachin Kumar <sachin.setiya@mariadb.com> committer: Sachin Kumar <sachin.setiya@mariadb.com> timestamp: 2021-06-11 14:26:19 +0100 message:
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.
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; + }
dunno, why would you duplicate the whole switch logic? can you just - return(REC_VERSION_56_MAX_INDEX_COL_LEN); - return MY_MIN(max_supported_key_length(), REC_VERSION_56_MAX_INDEX_COL_LEN);
}
/******************************************************************//**
Regards, Sergei VP of MariaDB Server Engineering and security@mariadb.org
participants (1)
-
Sergei Golubchik