| 9182 | |
| 9183 | |
| 9184 | bool Table_scope_and_contents_source_st::vers_check_system_fields( |
| 9185 | THD *thd, Alter_info *alter_info, const Lex_ident_table &table_name, |
| 9186 | const Lex_ident_db &db) |
| 9187 | { |
| 9188 | if (!(options & HA_VERSIONED_TABLE)) |
| 9189 | return false; |
| 9190 | |
| 9191 | uint versioned_fields= 0; |
| 9192 | |
| 9193 | if (!(alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING)) |
| 9194 | { |
| 9195 | uint fieldnr= 0; |
| 9196 | List_iterator<Create_field> field_it(alter_info->create_list); |
| 9197 | uint select_field_pos= (uint) get_select_field_pos(alter_info, true); |
| 9198 | while (Create_field *f= field_it++) |
| 9199 | { |
| 9200 | /* |
| 9201 | The field from the CREATE part can be duplicated in the SELECT part of |
| 9202 | CREATE...SELECT. In that case double counts should be avoided. |
| 9203 | select_create::create_table_from_items just pushes the fields back into |
| 9204 | the create_list, without additional manipulations, so the fields from |
| 9205 | SELECT go last there. |
| 9206 | */ |
| 9207 | bool is_dup= false; |
| 9208 | if (fieldnr >= select_field_pos && f->invisible < INVISIBLE_SYSTEM) |
| 9209 | { |
| 9210 | List_iterator<Create_field> dup_it(alter_info->create_list); |
| 9211 | for (Create_field *dup= dup_it++; !is_dup && dup != f; dup= dup_it++) |
| 9212 | is_dup= dup->field_name.streq(f->field_name); |
| 9213 | } |
| 9214 | |
| 9215 | if (!(f->flags & VERS_UPDATE_UNVERSIONED_FLAG) && !is_dup) |
| 9216 | versioned_fields++; |
| 9217 | fieldnr++; |
| 9218 | } |
| 9219 | if (versioned_fields == VERSIONING_FIELDS) |
| 9220 | { |
| 9221 | my_error(ER_VERS_TABLE_MUST_HAVE_COLUMNS, MYF(0), table_name.str); |
| 9222 | return true; |
| 9223 | } |
| 9224 | } |
| 9225 | |
| 9226 | if (!(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING) && !versioned_fields) |
| 9227 | return false; |
| 9228 | |
| 9229 | return vers_info.check_sys_fields(table_name, db, alter_info); |
| 9230 | } |
| 9231 | |
| 9232 | |
| 9233 | bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info, |
nothing calls this directly
no test coverage detected