1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-31297 Create table as select on system versioned tables do not

work consistently on replication

Row-based replication does not execute CREATE .. SELECT but instead
CREATE TABLE. CREATE .. SELECT creates implict system fields on
unusual place: in-between declared fields and select fields. That was
done because select_field_pos logic requires select fields go last in
create_list.

So, CREATE .. SELECT on master and CREATE TABLE on slave create system
fields on different positions and replication gets field mismatch.

To fix this we've changed CREATE .. SELECT to create implicit system
fields on usual place in the end and updated select_field_pos for
handling this case.
This commit is contained in:
Aleksey Midenkov
2024-10-08 13:08:10 +03:00
parent 4e4c7dd4f5
commit d37bb140b1
6 changed files with 74 additions and 5 deletions

View File

@ -4524,9 +4524,6 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items,
if (!(thd->variables.option_bits & OPTION_EXPLICIT_DEF_TIMESTAMP))
promote_first_timestamp_column(&alter_info->create_list);
if (create_info->fix_create_fields(thd, alter_info, *create_table))
DBUG_RETURN(NULL);
while ((item=it++))
{
Field *tmp_field= item->create_field_for_create_select(thd->mem_root,
@ -4564,6 +4561,9 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items,
alter_info->create_list.push_back(cr_field, thd->mem_root);
}
if (create_info->fix_create_fields(thd, alter_info, *create_table))
DBUG_RETURN(NULL);
/*
Item*::type_handler() always returns pointers to
type_handler_{time2|datetime2|timestamp2} no matter what