1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +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

@ -3634,7 +3634,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
DBUG_RETURN(TRUE);
}
select_field_pos= alter_info->create_list.elements - select_field_count;
select_field_pos= get_select_field_pos(alter_info, select_field_count,
create_info->versioned());
null_fields= 0;
create_info->varchar= 0;
max_key_length= file->max_key_length();
@ -3699,7 +3700,16 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
/*
If this was a CREATE ... SELECT statement, accept a field
redefinition if we are changing a field in the SELECT part
The cases are:
field_no < select_field_pos: both field and dup are table fields;
dup_no >= select_field_pos: both field and dup are select fields or
field is implicit systrem field and dup is select field.
We are not allowed to put row_start/row_end into SELECT expression.
*/
DBUG_ASSERT(dup_no < field_no);
if (field_no < select_field_pos || dup_no >= select_field_pos ||
dup_field->invisible >= INVISIBLE_SYSTEM)
{