Commit 9e2c26b0 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-26351 segfault - (MARIA_HA *) 0x0 in ha_maria::extra

don't let Aria create a table that it cannot open
parent 1b8bb441
...@@ -2630,5 +2630,5 @@ b as c2624, ...@@ -2630,5 +2630,5 @@ b as c2624,
b as c2626 b as c2626
from t1 from t1
) as tt1; ) 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; drop table t1;
...@@ -6,7 +6,7 @@ create table t1 ( ...@@ -6,7 +6,7 @@ create table t1 (
) engine=innodb; ) engine=innodb;
--replace_regex /'.*'/'tmp'/ --replace_regex /'.*'/'tmp'/
--error 126 --error 140
create table t2 as create table t2 as
select select
1 1
......
...@@ -716,9 +716,10 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -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.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)); DBUG_PRINT("info", ("info_length: %u", info_length));
/* There are only 16 bits for the total header 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, my_printf_error(HA_WRONG_CREATE_OPTION,
"Aria table '%s' has too many columns and/or " "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, ...@@ -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); maria_set_all_keys_active(share.state.key_map, keys);
share.base.keystart = share.state.state.key_file_length= share.base.keystart = share.state.state.key_file_length;
MY_ALIGN(info_length, maria_block_size);
share.base.max_key_block_length= maria_block_size; share.base.max_key_block_length= maria_block_size;
share.base.max_key_length=ALIGN_SIZE(max_key_length+4); share.base.max_key_length=ALIGN_SIZE(max_key_length+4);
share.base.records=ci->max_rows; share.base.records=ci->max_rows;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment