Commit d3df022f authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

refs #5431, put some defensive checks in for mysql 5.6 alter table in tokudb storage engine

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@47650 c7de825b-a66e-492c-adef-691d508d4ae1
parent c1c9b54d
......@@ -299,13 +299,19 @@ ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_
HA_CREATE_INFO *create_info = ha_alter_info->create_info;
// alter auto_increment
if (only_flags(create_info->used_fields, HA_CREATE_USED_AUTO)) {
// do a sanity check that the table is what we think it is
if (tables_have_same_keys_and_columns(table, altered_table, true)) {
result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
}
}
#ifndef MARIADB_BASE_VERSION
// alter row_format
else if (only_flags(create_info->used_fields, HA_CREATE_USED_ROW_FORMAT)) {
// do a sanity check that the table is what we think it is
if (tables_have_same_keys_and_columns(table, altered_table, true)) {
result = HA_ALTER_INPLACE_EXCLUSIVE_LOCK;
}
}
#endif
}
......
......@@ -677,3 +677,50 @@ find_changed_columns(
cleanup:
return retval;
}
static bool
tables_have_same_keys_and_columns(TABLE* first_table, TABLE* second_table, bool print_error) {
bool retval;
if (first_table->s->null_bytes != second_table->s->null_bytes) {
retval = false;
if (print_error) {
sql_print_error(
"tables have different number of null bytes, %d, %d",
first_table->s->null_bytes,
second_table->s->null_bytes
);
}
goto exit;
}
if (first_table->s->fields != second_table->s->fields) {
retval = false;
if (print_error) {
sql_print_error(
"tables have different number of fields, %d, %d",
first_table->s->fields,
second_table->s->fields
);
}
goto exit;
}
for (uint i = 0; i < first_table->s->fields; i++) {
Field* a = first_table->field[i];
Field* b = second_table->field[i];
if (!are_two_fields_same(a,b)) {
retval = false;
sql_print_error(
"tables have different fields at position %d",
i
);
goto exit;
}
}
if (!tables_have_same_keys(first_table, second_table, print_error, true)) {
retval = false;
goto exit;
}
retval = true;
exit:
return retval;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment