Skip to content

Commit 14364b0

Browse files
committed
MDEV-35236 Assertion `(mem_root->flags & 4) == 0' failed in safe_lexcstrdup_root
followup for MDEV-35092
1 parent 1a53048 commit 14364b0

File tree

6 files changed

+31
-16
lines changed

6 files changed

+31
-16
lines changed

mysql-test/main/vector2.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ execute stmt;
141141
Warnings:
142142
Note 1091 Can't DROP INDEX `v`; check that it exists
143143
execute stmt;
144+
prepare stmt from 'alter table t drop index if exists v, add vector (v)';
145+
execute stmt;
146+
execute stmt;
144147
show create table t;
145148
Table Create Table
146149
t CREATE TABLE `t` (

mysql-test/main/vector2.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ create table t (a int, v vector(10) not null);
112112
prepare stmt from 'alter table t drop index if exists v, add vector (v) max_edges_per_node=10';
113113
execute stmt;
114114
execute stmt;
115+
prepare stmt from 'alter table t drop index if exists v, add vector (v)';
116+
execute stmt;
117+
execute stmt;
115118
show create table t;
116119
drop table t;
117120
set mhnsw_distance_function= default;

sql/create_options.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void engine_option_value::link(engine_option_value **start,
5151
if (opt)
5252
{
5353
opt->value= Value(); /* remove previous value */
54-
opt->parsed= TRUE; /* and don't issue warnings for it anymore */
54+
opt->parsed= TRUE; /* and don't issue warnings for it anymore */
5555
}
5656
/*
5757
Add this option to the end of the list
@@ -226,9 +226,11 @@ static const size_t ha_option_type_sizeof[]=
226226

227227
bool extend_option_list(THD* thd, st_plugin_int *plugin, bool create,
228228
engine_option_value **option_list,
229-
ha_create_table_option *rules, MEM_ROOT *root)
229+
ha_create_table_option *rules)
230230
{
231231
DBUG_ENTER("extend_option_list");
232+
MEM_ROOT *root= thd->mem_root;
233+
bool extended= false;
232234

233235
for (ha_create_table_option *opt= rules; rules && opt->name; opt++)
234236
{
@@ -262,6 +264,12 @@ bool extend_option_list(THD* thd, st_plugin_int *plugin, bool create,
262264
{
263265
engine_option_value *val= new (root) engine_option_value(name,
264266
value, opt->type != HA_OPTION_TYPE_ULL);
267+
if (!extended)
268+
{
269+
void *pos= *option_list ? &(last->next) : option_list;
270+
thd->register_item_tree_change((Item**)pos);
271+
extended= true;
272+
}
265273
val->link(option_list, &last);
266274
}
267275
}
@@ -844,4 +852,3 @@ bool is_engine_option_known(engine_option_value *opt,
844852
}
845853
return false;
846854
}
847-

sql/create_options.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ bool parse_option_list(THD* thd, void *option_struct,
118118

119119
bool extend_option_list(THD* thd, st_plugin_int *plugin, bool create,
120120
engine_option_value **option_list,
121-
ha_create_table_option *rules, MEM_ROOT *root);
121+
ha_create_table_option *rules);
122122

123123
static inline bool extend_option_list(THD* thd, handlerton *hton, bool create,
124124
engine_option_value **option_list,
125-
ha_create_table_option *rules, MEM_ROOT *root)
125+
ha_create_table_option *rules)
126126
{
127127
return extend_option_list(thd, hton2plugin[hton->slot], create, option_list,
128-
rules, root);
128+
rules);
129129
}
130130

131131
bool engine_table_options_frm_read(const uchar *buff, size_t length,

sql/sql_class.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4811,14 +4811,19 @@ class THD: public THD_count, /* this must be first */
48114811
return !stmt_arena->is_conventional();
48124812
}
48134813

4814+
void register_item_tree_change(Item **place)
4815+
{
4816+
/* TODO: check for OOM condition here */
4817+
if (is_item_tree_change_register_required())
4818+
nocheck_register_item_tree_change(place, *place, mem_root);
4819+
}
4820+
48144821
void change_item_tree(Item **place, Item *new_value)
48154822
{
48164823
DBUG_ENTER("THD::change_item_tree");
48174824
DBUG_PRINT("enter", ("Register: %p (%p) <- %p",
48184825
*place, place, new_value));
4819-
/* TODO: check for OOM condition here */
4820-
if (is_item_tree_change_register_required())
4821-
nocheck_register_item_tree_change(place, *place, mem_root);
4826+
register_item_tree_change(place);
48224827
*place= new_value;
48234828
DBUG_VOID_RETURN;
48244829
}

sql/sql_table.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,8 +3006,7 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
30063006
auto_increment++;
30073007
extend_option_list(thd, create_info->db_type, !sql_field->field,
30083008
&sql_field->option_list,
3009-
create_info->db_type->field_options,
3010-
thd->stmt_arena->mem_root);
3009+
create_info->db_type->field_options);
30113010
if (parse_option_list(thd, &sql_field->option_struct,
30123011
&sql_field->option_list,
30133012
create_info->db_type->field_options, FALSE,
@@ -3295,7 +3294,7 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
32953294
key_info->algorithm= key->key_create_info.algorithm;
32963295
key_info->option_list= key->option_list;
32973296
extend_option_list(thd, index_plugin, !key->old, &key_info->option_list,
3298-
index_options, thd->stmt_arena->mem_root);
3297+
index_options);
32993298
if (parse_option_list(thd, &key_info->option_struct, &key_info->option_list,
33003299
index_options, FALSE, thd->mem_root))
33013300
DBUG_RETURN(TRUE);
@@ -3891,10 +3890,8 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
38913890
ER_THD(thd, ER_UNKNOWN_OPTION), "transactional");
38923891

38933892
extend_option_list(thd, file->partition_ht(),
3894-
create_table_mode > C_ALTER_TABLE,
3895-
&create_info->option_list,
3896-
file->partition_ht()->table_options,
3897-
thd->stmt_arena->mem_root);
3893+
!thd->lex->create_like() && create_table_mode > C_ALTER_TABLE,
3894+
&create_info->option_list, file->partition_ht()->table_options);
38983895
if (parse_option_list(thd, &create_info->option_struct,
38993896
&create_info->option_list,
39003897
file->partition_ht()->table_options, FALSE,

0 commit comments

Comments
 (0)