1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-20494 ER_NOT_FORM_FILE or assertion upon adding partition to period table

- Fixed mysql_prepare_create_table() constraint duplicate checking;
- Refactored period constraint handling in mysql_prepare_alter_table():
  * No need to allocate new objects;
  * Keep old constraint name but exclude it from dup checking by automatic_name;
- Some minor memory leaks fixed;
- Some conceptual TODOs.
This commit is contained in:
Aleksey Midenkov
2020-04-03 23:55:48 +03:00
parent a219006636
commit 76063c2a13
7 changed files with 87 additions and 12 deletions

View File

@ -4311,6 +4311,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
const Virtual_column_info *dup_check;
while ((dup_check= dup_it++) && dup_check != check)
{
if (!dup_check->name.length || dup_check->automatic_name)
continue;
if (!lex_string_cmp(system_charset_info,
&check->name, &dup_check->name))
{
@ -8480,8 +8482,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
key_part_length= 0; // Use whole field
}
key_part_length /= kfield->charset()->mbmaxlen;
key_parts.push_back(new Key_part_spec(&cfield->field_name,
key_part_length),
key_parts.push_back(new (thd->mem_root) Key_part_spec(
&cfield->field_name, key_part_length),
thd->mem_root);
}
if (table->s->tmp_table == NO_TMP_TABLE)
@ -8547,7 +8549,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
tmp_name.str= key_name;
tmp_name.length= strlen(key_name);
/* We dont need LONG_UNIQUE_HASH_FIELD flag because it will be autogenerated */
key= new Key(key_type, &tmp_name, &key_create_info,
key= new (thd->mem_root) Key(key_type, &tmp_name, &key_create_info,
MY_TEST(key_info->flags & HA_GENERATED_KEY),
&key_parts, key_info->option_list, DDL_options());
new_key_list.push_back(key, thd->mem_root);
@ -8627,26 +8629,37 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
}
}
// NB: `check` is TABLE resident, we must keep it intact.
if (keep)
{
check= check->clone(thd);
if (!check)
{
my_error(ER_OUT_OF_RESOURCES, MYF(0));
goto err;
}
}
if (share->period.constr_name.streq(check->name.str))
{
if (!drop_period && !keep)
if (drop_period)
{
keep= false;
}
else if(!keep)
{
my_error(ER_PERIOD_CONSTRAINT_DROP, MYF(0), check->name.str,
share->period.name.str);
goto err;
}
keep= keep && !drop_period;
DBUG_ASSERT(create_info->period_info.constr == NULL || drop_period);
if (keep)
else
{
Item *expr_copy= check->expr->get_copy(thd);
check= new Virtual_column_info();
check->expr= expr_copy;
DBUG_ASSERT(create_info->period_info.constr == NULL);
create_info->period_info.constr= check;
create_info->period_info.constr->automatic_name= true;
}
}
/* see if the constraint depends on *only* on dropped fields */
if (keep && dropped_fields)
{