From 9e2c26b0f6d91b3b6b0deaf9bc82f6e6ebf9a90b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 10 Feb 2022 13:40:03 +0100 Subject: MDEV-26351 segfault - (MARIA_HA *) 0x0 in ha_maria::extra don't let Aria create a table that it cannot open --- mysql-test/r/tmp_table_error.result | 2 +- mysql-test/t/tmp_table_error.test | 2 +- storage/maria/ma_create.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/tmp_table_error.result b/mysql-test/r/tmp_table_error.result index c0c8b203dfb..3a1a9725001 100644 --- a/mysql-test/r/tmp_table_error.result +++ b/mysql-test/r/tmp_table_error.result @@ -2630,5 +2630,5 @@ b as c2624, b as c2626 from t1 ) as tt1; -ERROR HY000: Index for table 'tmp' is corrupt; try to repair it +ERROR 0A000: Aria table 'tmp' has too many columns and/or indexes and/or unique constraints. drop table t1; diff --git a/mysql-test/t/tmp_table_error.test b/mysql-test/t/tmp_table_error.test index e09e45085fa..dbddaaaa4c7 100644 --- a/mysql-test/t/tmp_table_error.test +++ b/mysql-test/t/tmp_table_error.test @@ -6,7 +6,7 @@ create table t1 ( ) engine=innodb; --replace_regex /'.*'/'tmp'/ ---error 126 +--error 140 create table t2 as select 1 diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c index dc041b79f06..6dd1d1b1a3a 100644 --- a/storage/maria/ma_create.c +++ b/storage/maria/ma_create.c @@ -716,9 +716,10 @@ int maria_create(const char *name, enum data_file_type datafile_type, share.base.extra_options|= MA_EXTRA_OPTIONS_INSERT_ORDER; } + share.state.state.key_file_length= MY_ALIGN(info_length, maria_block_size); DBUG_PRINT("info", ("info_length: %u", info_length)); /* There are only 16 bits for the total header length. */ - if (info_length > 65535) + if (share.state.state.key_file_length > 65535) { my_printf_error(HA_WRONG_CREATE_OPTION, "Aria table '%s' has too many columns and/or " @@ -775,8 +776,7 @@ int maria_create(const char *name, enum data_file_type datafile_type, maria_set_all_keys_active(share.state.key_map, keys); - share.base.keystart = share.state.state.key_file_length= - MY_ALIGN(info_length, maria_block_size); + share.base.keystart = share.state.state.key_file_length; share.base.max_key_block_length= maria_block_size; share.base.max_key_length=ALIGN_SIZE(max_key_length+4); share.base.records=ci->max_rows; -- cgit v1.2.1