diff options
-rw-r--r-- | sql/handler.cc | 9 | ||||
-rw-r--r-- | sql/sql_parse.cc | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index b3f957b6737..653d7c017ac 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6995,6 +6995,13 @@ bool Table_scope_and_contents_source_st::vers_check_system_fields( List_iterator<Create_field> field_it(alter_info->create_list); while (Create_field *f= field_it++) { + /* + The field from the CREATE part can be duplicated in the SELECT part of + CREATE...SELECT. In that case double counts should be avoided. + select_create::create_table_from_items just pushes the fields back into + the create_list, without additional manipulations, so the fields from + SELECT go last there. + */ bool is_dup= false; if (fieldnr >= alter_info->create_list.elements - select_count) { @@ -7018,8 +7025,6 @@ bool Table_scope_and_contents_source_st::vers_check_system_fields( if (!(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING)) return false; - if (!(options & HA_VERSIONED_TABLE)) - return false; return vers_info.check_sys_fields(table_name, db, alter_info, vers_native(thd)); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 35b841d8b94..516ea5f9205 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4257,7 +4257,7 @@ mysql_execute_command(THD *thd) if (create_info.vers_fix_system_fields(thd, &alter_info, *create_table) || create_info.vers_check_system_fields(thd, &alter_info, create_table->table_name, - create_table->db, 0)) + create_table->db)) goto end_with_restore_list; /* |