MDEV-35236 Assertion `(mem_root->flags & 4) == 0' failed in safe_lexcstrdup_root

followup for MDEV-35092
This commit is contained in:
Sergei Golubchik 2024-10-23 14:25:11 +02:00
parent 1a53048299
commit 14364b09b9
6 changed files with 31 additions and 16 deletions

View file

@ -141,6 +141,9 @@ execute stmt;
Warnings:
Note 1091 Can't DROP INDEX `v`; check that it exists
execute stmt;
prepare stmt from 'alter table t drop index if exists v, add vector (v)';
execute stmt;
execute stmt;
show create table t;
Table Create Table
t CREATE TABLE `t` (

View file

@ -112,6 +112,9 @@ create table t (a int, v vector(10) not null);
prepare stmt from 'alter table t drop index if exists v, add vector (v) max_edges_per_node=10';
execute stmt;
execute stmt;
prepare stmt from 'alter table t drop index if exists v, add vector (v)';
execute stmt;
execute stmt;
show create table t;
drop table t;
set mhnsw_distance_function= default;

View file

@ -51,7 +51,7 @@ void engine_option_value::link(engine_option_value **start,
if (opt)
{
opt->value= Value(); /* remove previous value */
opt->parsed= TRUE; /* and don't issue warnings for it anymore */
opt->parsed= TRUE; /* and don't issue warnings for it anymore */
}
/*
Add this option to the end of the list
@ -226,9 +226,11 @@ static const size_t ha_option_type_sizeof[]=
bool extend_option_list(THD* thd, st_plugin_int *plugin, bool create,
engine_option_value **option_list,
ha_create_table_option *rules, MEM_ROOT *root)
ha_create_table_option *rules)
{
DBUG_ENTER("extend_option_list");
MEM_ROOT *root= thd->mem_root;
bool extended= false;
for (ha_create_table_option *opt= rules; rules && opt->name; opt++)
{
@ -262,6 +264,12 @@ bool extend_option_list(THD* thd, st_plugin_int *plugin, bool create,
{
engine_option_value *val= new (root) engine_option_value(name,
value, opt->type != HA_OPTION_TYPE_ULL);
if (!extended)
{
void *pos= *option_list ? &(last->next) : option_list;
thd->register_item_tree_change((Item**)pos);
extended= true;
}
val->link(option_list, &last);
}
}
@ -844,4 +852,3 @@ bool is_engine_option_known(engine_option_value *opt,
}
return false;
}

View file

@ -118,14 +118,14 @@ bool parse_option_list(THD* thd, void *option_struct,
bool extend_option_list(THD* thd, st_plugin_int *plugin, bool create,
engine_option_value **option_list,
ha_create_table_option *rules, MEM_ROOT *root);
ha_create_table_option *rules);
static inline bool extend_option_list(THD* thd, handlerton *hton, bool create,
engine_option_value **option_list,
ha_create_table_option *rules, MEM_ROOT *root)
ha_create_table_option *rules)
{
return extend_option_list(thd, hton2plugin[hton->slot], create, option_list,
rules, root);
rules);
}
bool engine_table_options_frm_read(const uchar *buff, size_t length,

View file

@ -4811,14 +4811,19 @@ public:
return !stmt_arena->is_conventional();
}
void register_item_tree_change(Item **place)
{
/* TODO: check for OOM condition here */
if (is_item_tree_change_register_required())
nocheck_register_item_tree_change(place, *place, mem_root);
}
void change_item_tree(Item **place, Item *new_value)
{
DBUG_ENTER("THD::change_item_tree");
DBUG_PRINT("enter", ("Register: %p (%p) <- %p",
*place, place, new_value));
/* TODO: check for OOM condition here */
if (is_item_tree_change_register_required())
nocheck_register_item_tree_change(place, *place, mem_root);
register_item_tree_change(place);
*place= new_value;
DBUG_VOID_RETURN;
}

View file

@ -3006,8 +3006,7 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
auto_increment++;
extend_option_list(thd, create_info->db_type, !sql_field->field,
&sql_field->option_list,
create_info->db_type->field_options,
thd->stmt_arena->mem_root);
create_info->db_type->field_options);
if (parse_option_list(thd, &sql_field->option_struct,
&sql_field->option_list,
create_info->db_type->field_options, FALSE,
@ -3295,7 +3294,7 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
key_info->algorithm= key->key_create_info.algorithm;
key_info->option_list= key->option_list;
extend_option_list(thd, index_plugin, !key->old, &key_info->option_list,
index_options, thd->stmt_arena->mem_root);
index_options);
if (parse_option_list(thd, &key_info->option_struct, &key_info->option_list,
index_options, FALSE, thd->mem_root))
DBUG_RETURN(TRUE);
@ -3891,10 +3890,8 @@ without_overlaps_err:
ER_THD(thd, ER_UNKNOWN_OPTION), "transactional");
extend_option_list(thd, file->partition_ht(),
create_table_mode > C_ALTER_TABLE,
&create_info->option_list,
file->partition_ht()->table_options,
thd->stmt_arena->mem_root);
!thd->lex->create_like() && create_table_mode > C_ALTER_TABLE,
&create_info->option_list, file->partition_ht()->table_options);
if (parse_option_list(thd, &create_info->option_struct,
&create_info->option_list,
file->partition_ht()->table_options, FALSE,