From a586b6dbc81b788106cee0f88416c389ae79d26c Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 29 Apr 2024 16:42:26 +0530 Subject: [PATCH] MDEV-22855 Assertion `!field->prefix_len || field->fixed_len == field->prefix_len' failed in btr_node_ptr_max_size Problem: ======== - InnoDB wrongly calulates the record size in btr_node_ptr_max_size() when prefix index of the column has to be stored externally. Fix: ==== - InnoDB should add the maximum field size to record size when the field is a fixed length one. --- mysql-test/suite/innodb/r/index_length.result | 8 ++++++++ mysql-test/suite/innodb/t/index_length.test | 8 ++++++++ storage/innobase/btr/btr0cur.cc | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/index_length.result b/mysql-test/suite/innodb/r/index_length.result index cc92780ac32..e0d6a735bb4 100644 --- a/mysql-test/suite/innodb/r/index_length.result +++ b/mysql-test/suite/innodb/r/index_length.result @@ -20,4 +20,12 @@ FLOOR(index_length/@@innodb_page_size) 2 disconnect stop_purge; DROP TABLE t1; +# +# MDEV-22855 Assertion (!field->prefix_len || +# field->fixed_len == field->prefix_len) +# failed in btr_node_ptr_max_size +# +CREATE TABLE t1(c CHAR(194) CHARACTER SET UTF32, KEY k1(c(193)))ENGINE=InnoDB; +INSERT INTO t1 SET c=''; +DROP TABLE t1; # End of 10.4 tests diff --git a/mysql-test/suite/innodb/t/index_length.test b/mysql-test/suite/innodb/t/index_length.test index bf4940d4b39..03e61a5a8f9 100644 --- a/mysql-test/suite/innodb/t/index_length.test +++ b/mysql-test/suite/innodb/t/index_length.test @@ -20,4 +20,12 @@ WHERE table_schema = 'test' AND table_name = 't1'; disconnect stop_purge; DROP TABLE t1; +--echo # +--echo # MDEV-22855 Assertion (!field->prefix_len || +--echo # field->fixed_len == field->prefix_len) +--echo # failed in btr_node_ptr_max_size +--echo # +CREATE TABLE t1(c CHAR(194) CHARACTER SET UTF32, KEY k1(c(193)))ENGINE=InnoDB; +INSERT INTO t1 SET c=''; +DROP TABLE t1; --echo # End of 10.4 tests diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index bd88582d4f4..bc9abd77a81 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -1126,7 +1126,7 @@ static ulint btr_node_ptr_max_size(const dict_index_t* index) /* Determine the maximum length of the index field. */ field_max_size = dict_col_get_fixed_size(col, comp); - if (field_max_size) { + if (field_max_size && field->fixed_len) { /* dict_index_add_col() should guarantee this */ ut_ad(!field->prefix_len || field->fixed_len == field->prefix_len);