diff options
author | Nikita Malyavin <nikitamalyavin@gmail.com> | 2021-10-07 15:04:56 +0300 |
---|---|---|
committer | Nikita Malyavin <nikitamalyavin@gmail.com> | 2021-10-20 16:49:28 +0300 |
commit | d10c42b42541deed899dd1d1e04b69475339196c (patch) | |
tree | e1cbd843034cea12a59acd32b95d41092607cb34 /mysql-test | |
parent | 4590f8b41cfec0c98a96e5980b6ad7b2e250818c (diff) | |
download | mariadb-git-d10c42b42541deed899dd1d1e04b69475339196c.tar.gz |
MDEV-20131 Assertion `!pk->has_virtual()' failed
Assertion `!pk->has_virtual()' failed in dict_index_build_internal_clust
while creating PRIMARY key longer than possible to store in the page.
This happened because the key was wrongly deduced as Long UNIQUE supported,
however PRIMARY KEY cannot be of that type. The main reason is that
only 8 bytes are used to store the hash, see HA_HASH_FIELD_LENGTH.
This is also why HA_NOSAME flag is removed (and caused the assertion in
turn) in open_table_from_share:
if (key_info->algorithm == HA_KEY_ALG_LONG_HASH)
{
key_part_end++;
key_info->flags&= ~HA_NOSAME;
}
To make it unique, the additional check is done by
check_duplicate_long_entries call from ha_write_row, and similar one from
ha_update_row.
PRIMARY key is already forbidden, which is checked by the first test in
main.long_unique, however is_hash_field_needed was wrongly deduced to true
in mysql_prepare_create_table in this particular case.
FIX:
* Improve the check for Key::PRIMARY type
* Simplify is_hash_field_needed deduction for a more neat reading
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/main/long_unique_innodb.opt | 1 | ||||
-rw-r--r-- | mysql-test/main/long_unique_innodb.result | 3 | ||||
-rw-r--r-- | mysql-test/main/long_unique_innodb.test | 5 |
3 files changed, 9 insertions, 0 deletions
diff --git a/mysql-test/main/long_unique_innodb.opt b/mysql-test/main/long_unique_innodb.opt new file mode 100644 index 00000000000..058a129cdc2 --- /dev/null +++ b/mysql-test/main/long_unique_innodb.opt @@ -0,0 +1 @@ +--innodb-page-size=8K diff --git a/mysql-test/main/long_unique_innodb.result b/mysql-test/main/long_unique_innodb.result index 135bb0808cc..96e5fac7310 100644 --- a/mysql-test/main/long_unique_innodb.result +++ b/mysql-test/main/long_unique_innodb.result @@ -131,3 +131,6 @@ connection default; drop table t1; disconnect con1; disconnect con2; +# MDEV-20131 Assertion `!pk->has_virtual()' failed +create table t1 (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_innodb.test b/mysql-test/main/long_unique_innodb.test index aac68cd2271..dd2d9f94de3 100644 --- a/mysql-test/main/long_unique_innodb.test +++ b/mysql-test/main/long_unique_innodb.test @@ -138,3 +138,8 @@ connection default; drop table t1; disconnect con1; disconnect con2; + +--echo # MDEV-20131 Assertion `!pk->has_virtual()' failed + +--error ER_TOO_LONG_KEY +create table t1 (a text, primary key(a(1871))) engine=innodb; |