Commit 37a86b93 authored by Aleksey Midenkov's avatar Aleksey Midenkov

Merge 10.3 into 10.4

parents 3708bef6 074e3582
...@@ -567,4 +567,13 @@ SELECT * FROM t3; ...@@ -567,4 +567,13 @@ SELECT * FROM t3;
ERROR HY000: Table 't3' was not locked with LOCK TABLES ERROR HY000: Table 't3' was not locked with LOCK TABLES
UNLOCK TABLES; UNLOCK TABLES;
DROP TABLE t3; DROP TABLE t3;
#
# MDEV-29697 Assertion failure in Diagnostics_area::set_ok_status
# upon CREATE OR REPLACE causing ER_UPDATE_TABLE_USED
#
CREATE TABLE t (a INT) ENGINE=MyISAM;
CREATE TABLE tm (a INT) ENGINE=MERGE UNION(t);
CREATE OR REPLACE TABLE t LIKE tm;
ERROR HY000: Table 'tm' is specified twice, both as a target for 'CREATE' and as a separate source for data
DROP TABLE IF EXISTS tm, t;
# End of 10.4 tests # End of 10.4 tests
...@@ -507,4 +507,16 @@ SELECT * FROM t3; ...@@ -507,4 +507,16 @@ SELECT * FROM t3;
UNLOCK TABLES; UNLOCK TABLES;
DROP TABLE t3; DROP TABLE t3;
--echo #
--echo # MDEV-29697 Assertion failure in Diagnostics_area::set_ok_status
--echo # upon CREATE OR REPLACE causing ER_UPDATE_TABLE_USED
--echo #
CREATE TABLE t (a INT) ENGINE=MyISAM;
CREATE TABLE tm (a INT) ENGINE=MERGE UNION(t);
--error ER_UPDATE_TABLE_USED
CREATE OR REPLACE TABLE t LIKE tm;
# Cleanup
DROP TABLE IF EXISTS tm, t;
--echo # End of 10.4 tests --echo # End of 10.4 tests
...@@ -200,4 +200,15 @@ pk ...@@ -200,4 +200,15 @@ pk
2 2
delete from t1; delete from t1;
drop table t1; drop table t1;
#
# MDEV-28576 RENAME COLUMN with NOCOPY algorithm leads to corrupt partitioned table
#
create table t (a int, b int) partition by list (b) (partition p1 values in (1, 2));
insert into t values (0, 1), (2, 2);
alter table t change b f int, change a b int, algorithm=nocopy;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
delete from t order by b limit 1;
drop table t;
# End of 10.3 tests # End of 10.3 tests
...@@ -185,4 +185,15 @@ select * from t1 partition(p1); ...@@ -185,4 +185,15 @@ select * from t1 partition(p1);
delete from t1; delete from t1;
drop table t1; drop table t1;
--echo #
--echo # MDEV-28576 RENAME COLUMN with NOCOPY algorithm leads to corrupt partitioned table
--echo #
create table t (a int, b int) partition by list (b) (partition p1 values in (1, 2));
insert into t values (0, 1), (2, 2);
alter table t change b f int, change a b int, algorithm=nocopy;
check table t;
delete from t order by b limit 1;
# cleanup
drop table t;
--echo # End of 10.3 tests --echo # End of 10.3 tests
...@@ -119,8 +119,8 @@ struct list_node :public Sql_alloc ...@@ -119,8 +119,8 @@ struct list_node :public Sql_alloc
{ {
list_node *next; list_node *next;
void *info; void *info;
list_node(void *info_par,list_node *next_par) list_node(const void *info_par, list_node *next_par)
:next(next_par),info(info_par) :next(next_par), info(const_cast<void *>(info_par))
{} {}
list_node() /* For end_of_list */ list_node() /* For end_of_list */
{ {
...@@ -385,7 +385,7 @@ class base_list :public Sql_alloc ...@@ -385,7 +385,7 @@ class base_list :public Sql_alloc
#endif // LIST_EXTRA_DEBUG #endif // LIST_EXTRA_DEBUG
protected: protected:
void after(void *info,list_node *node) void after(const void *info, list_node *node)
{ {
list_node *new_node=new list_node(info,node->next); list_node *new_node=new list_node(info,node->next);
node->next=new_node; node->next=new_node;
...@@ -446,11 +446,11 @@ class base_list_iterator ...@@ -446,11 +446,11 @@ class base_list_iterator
{ {
el= &list->first; el= &list->first;
} }
inline void *replace(void *element) inline void *replace(const void *element)
{ // Return old element { // Return old element
void *tmp=current->info; void *tmp=current->info;
DBUG_ASSERT(current->info != 0); DBUG_ASSERT(current->info != 0);
current->info=element; current->info= const_cast<void *>(element);
return tmp; return tmp;
} }
void *replace(base_list &new_list) void *replace(base_list &new_list)
...@@ -473,7 +473,7 @@ class base_list_iterator ...@@ -473,7 +473,7 @@ class base_list_iterator
el=prev; el=prev;
current=0; // Safeguard current=0; // Safeguard
} }
void after(void *element) // Insert element after current void after(const void *element) // Insert element after current
{ {
list->after(element,current); list->after(element,current);
current=current->next; current=current->next;
......
...@@ -5772,6 +5772,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, ...@@ -5772,6 +5772,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
if ((duplicate= unique_table(thd, table, src_table, 0))) if ((duplicate= unique_table(thd, table, src_table, 0)))
{ {
update_non_unique_table_error(src_table, "CREATE", duplicate); update_non_unique_table_error(src_table, "CREATE", duplicate);
res= 1;
goto err; goto err;
} }
} }
...@@ -8055,6 +8056,20 @@ void append_drop_column(THD *thd, String *str, Field *field) ...@@ -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. Prepare column and key definitions for CREATE TABLE in ALTER TABLE.
...@@ -8365,6 +8380,39 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, ...@@ -8365,6 +8380,39 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
new_create_tail.push_back(def, thd->mem_root); 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; dropped_sys_vers_fields &= VERS_SYSTEM_FIELD;
if ((dropped_sys_vers_fields || if ((dropped_sys_vers_fields ||
alter_info->flags & ALTER_DROP_PERIOD) && alter_info->flags & ALTER_DROP_PERIOD) &&
......
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