MDEV-5800 InnoDB support for indexed vcols

* remove old 5.2+ InnoDB support for virtual columns
  * enable corresponding parts of the innodb-5.7 sources
  * copy corresponding test cases from 5.7
  * copy detailed Alter_inplace_info::HA_ALTER_FLAGS flags from 5.7
     - and more detailed detection of changes in fill_alter_inplace_info()
  * more "innodb compatibility hooks" in sql_class.cc to
     - create/destroy/reset a THD (used by background purge threads)
     - find a prelocked table by name
     - open a table (from a background purge thread)

  * different from 5.7:
    - new service thread "thd_destructor_proxy" to make sure all THDs are
      destroyed at the correct point in time during the server shutdown
    - proper opening/closing of tables for vcol evaluations in
       + FK checks (use already opened prelocked tables)
       + purge threads (open the table, MDLock it, add it to tdc, close
         when not needed)
    - cache open tables in vc_templ
    - avoid unnecessary allocations, reuse table->record[0] and table->s->default_values
    - not needed in 5.7, because it overcalculates:
      + tell the server to calculate vcols for an on-going inline ADD INDEX
      + calculate vcols for correct error messages

  * update other engines (mroonga/tokudb) accordingly
This commit is contained in:
Sergei Golubchik 2016-11-07 22:35:02 +01:00
commit 1cae1af6f9
65 changed files with 7371 additions and 1110 deletions

View file

@ -216,11 +216,11 @@ static ulong fix_handler_flags(
handler_flags &= ~Alter_inplace_info::TOKU_ALTER_RENAME;
}
// ALTER_COLUMN_TYPE may be set when no columns have been changed,
// ALTER_STORED_COLUMN_TYPE may be set when no columns have been changed,
// so turn off the flag
if (handler_flags & Alter_inplace_info::ALTER_COLUMN_TYPE) {
if (handler_flags & Alter_inplace_info::ALTER_STORED_COLUMN_TYPE) {
if (all_fields_are_same_type(table, altered_table)) {
handler_flags &= ~Alter_inplace_info::ALTER_COLUMN_TYPE;
handler_flags &= ~Alter_inplace_info::ALTER_STORED_COLUMN_TYPE;
}
}
@ -358,7 +358,7 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(
// but let's do some more checks
// we will only allow an hcr if there are no changes
// in column positions (ALTER_COLUMN_ORDER is not set)
// in column positions (ALTER_STORED_COLUMN_ORDER is not set)
// now need to verify that one and only one column
// has changed only its name. If we find anything to
@ -369,7 +369,7 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(
table,
altered_table,
(ctx->handler_flags &
Alter_inplace_info::ALTER_COLUMN_ORDER) != 0);
Alter_inplace_info::ALTER_STORED_COLUMN_ORDER) != 0);
if (cr_supported)
result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
}
@ -377,7 +377,7 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(
only_flags(
ctx->handler_flags,
Alter_inplace_info::ADD_COLUMN +
Alter_inplace_info::ALTER_COLUMN_ORDER) &&
Alter_inplace_info::ALTER_STORED_COLUMN_ORDER) &&
setup_kc_info(altered_table, ctx->altered_table_kc_info) == 0) {
// add column
@ -407,7 +407,7 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(
only_flags(
ctx->handler_flags,
Alter_inplace_info::DROP_COLUMN +
Alter_inplace_info::ALTER_COLUMN_ORDER) &&
Alter_inplace_info::ALTER_STORED_COLUMN_ORDER) &&
setup_kc_info(altered_table, ctx->altered_table_kc_info) == 0) {
// drop column
@ -452,10 +452,10 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(
ha_alter_info, ctx)) {
result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
}
} else if ((ctx->handler_flags & Alter_inplace_info::ALTER_COLUMN_TYPE) &&
} else if ((ctx->handler_flags & Alter_inplace_info::ALTER_STORED_COLUMN_TYPE) &&
only_flags(
ctx->handler_flags,
Alter_inplace_info::ALTER_COLUMN_TYPE +
Alter_inplace_info::ALTER_STORED_COLUMN_TYPE +
Alter_inplace_info::ALTER_COLUMN_DEFAULT) &&
table->s->fields == altered_table->s->fields &&
find_changed_fields(
@ -1578,7 +1578,7 @@ static bool change_field_type_is_supported(
return false;
} else if (old_type == MYSQL_TYPE_VARCHAR) {
// varchar(X) -> varchar(Y) and varbinary(X) -> varbinary(Y) expansion
// where X < 256 <= Y the ALTER_COLUMN_TYPE handler flag is set for
// where X < 256 <= Y the ALTER_STORED_COLUMN_TYPE handler flag is set for
// these cases
return change_varchar_length_is_supported(
old_field,