diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2022-10-06 23:37:42 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2022-10-06 23:37:42 +0300 |
commit | 37a86b933e8fc2489b32dff40e7e47d4d5c679ba (patch) | |
tree | 2a1a1c3727bd012b52e506f6011dd742e6cd76cd /sql/sql_table.cc | |
parent | 3708bef60683dc7b6020ee76e90738528ccad18a (diff) | |
parent | 074e358213ac8f358fa01c2c03ed58e94c81baf8 (diff) | |
download | mariadb-git-37a86b933e8fc2489b32dff40e7e47d4d5c679ba.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2436031200a..6aae927800e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5772,6 +5772,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, if ((duplicate= unique_table(thd, table, src_table, 0))) { update_non_unique_table_error(src_table, "CREATE", duplicate); + res= 1; goto err; } } @@ -8055,6 +8056,20 @@ void append_drop_column(THD *thd, String *str, Field *field) } +static inline +void rename_field_in_list(Create_field *field, List<const char> *field_list) +{ + DBUG_ASSERT(field->change.str); + List_iterator<const char> it(*field_list); + while (const char *name= it++) + { + if (my_strcasecmp(system_charset_info, name, field->change.str)) + continue; + it.replace(field->field_name.str); + } +} + + /** Prepare column and key definitions for CREATE TABLE in ALTER TABLE. @@ -8365,6 +8380,39 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, new_create_tail.push_back(def, thd->mem_root); } } + +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (alter_info->flags & ALTER_RENAME_COLUMN) + { + if (thd->work_part_info) + { + partition_info *part_info= thd->work_part_info; + List_iterator<Create_field> def_it(column_rename_param.fields); + const bool part_field_list= !part_info->part_field_list.is_empty(); + const bool subpart_field_list= !part_info->subpart_field_list.is_empty(); + if (part_info->part_expr) + part_info->part_expr->walk(&Item::rename_fields_processor, 1, + &column_rename_param); + if (part_info->subpart_expr) + part_info->subpart_expr->walk(&Item::rename_fields_processor, 1, + &column_rename_param); + if (part_field_list || subpart_field_list) + { + while (Create_field *def= def_it++) + { + if (def->change.str) + { + if (part_field_list) + rename_field_in_list(def, &part_info->part_field_list); + if (subpart_field_list) + rename_field_in_list(def, &part_info->subpart_field_list); + } /* if (def->change.str) */ + } /* while (def) */ + } /* if (part_field_list || subpart_field_list) */ + } /* if (part_info) */ + } +#endif + dropped_sys_vers_fields &= VERS_SYSTEM_FIELD; if ((dropped_sys_vers_fields || alter_info->flags & ALTER_DROP_PERIOD) && |