MDEV-8589: Non-default ENCRYPTION_KEY_ID is ignored upon reading a table

Analysis: Problem was that when a new tablespace is created a default
encryption info is also created and stored to the tablespace. Later a
new encryption information was created with correct key_id but that
does not affect on IV.

Fix: Push encryption mode and key_id to lower levels and create
correct encryption info when a new tablespace is created.

This fix does not contain test case because, currently incorrect
encryption key causes page corruption and a lot of error messages
to error log causing mtr to fail.
This commit is contained in:
Jan Lindström 2015-08-14 11:09:06 +03:00
commit bfb6ea0232
22 changed files with 154 additions and 140 deletions

View file

@ -2791,6 +2791,7 @@ prepare_inplace_alter_table_dict(
to rebuild the table with a temporary name. */
if (new_clustered) {
fil_space_crypt_t* crypt_data;
const char* new_table_name
= dict_mem_create_temporary_tablename(
ctx->heap,
@ -2798,6 +2799,15 @@ prepare_inplace_alter_table_dict(
ctx->new_table->id);
ulint n_cols;
dtuple_t* add_cols;
ulint key_id = FIL_DEFAULT_ENCRYPTION_KEY;
fil_encryption_t mode = FIL_SPACE_ENCRYPTION_DEFAULT;
crypt_data = fil_space_get_crypt_data(ctx->prebuilt->table->space);
if (crypt_data) {
key_id = crypt_data->key_id;
mode = crypt_data->encryption;
}
if (innobase_check_foreigns(
ha_alter_info, altered_table, old_table,
@ -2929,7 +2939,7 @@ prepare_inplace_alter_table_dict(
}
error = row_create_table_for_mysql(
ctx->new_table, ctx->trx, false);
ctx->new_table, ctx->trx, false, mode, key_id);
switch (error) {
dict_table_t* temp_table;