Skip to content

Commit ee768d8

Browse files
author
Jan Lindström
committed
MDEV-9640: Add used key_id to INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION
1 parent 4aac51d commit ee768d8

File tree

12 files changed

+88
-16
lines changed

12 files changed

+88
-16
lines changed

mysql-test/suite/encryption/r/innodb_encryption.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ MIN_KEY_VERSION int(11) unsigned NO 0
1616
CURRENT_KEY_VERSION int(11) unsigned NO 0
1717
KEY_ROTATION_PAGE_NUMBER bigint(21) unsigned YES NULL
1818
KEY_ROTATION_MAX_PAGE_NUMBER bigint(21) unsigned YES NULL
19+
CURRENT_KEY_ID int(11) unsigned NO 0
1920
# Wait max 5 min for key encryption threads to encrypt one space
2021
# Success!
2122
# Wait max 10 min for key encryption threads to encrypt all space
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
SET GLOBAL innodb_file_format = `Barracuda`;
2+
SET GLOBAL innodb_file_per_table = ON;
3+
CREATE TABLE t1 (c VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=1;
4+
CREATE TABLE t2 (c VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=2;
5+
INSERT INTO t1 VALUES ('foobar');
6+
INSERT INTO t2 VALUES ('foobar');
7+
SELECT NAME, ENCRYPTION_SCHEME, MIN_KEY_VERSION, CURRENT_KEY_VERSION,
8+
CURRENT_KEY_ID
9+
FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION
10+
WHERE NAME LIKE '%t1' OR NAME LIKE '%t2';
11+
NAME ENCRYPTION_SCHEME MIN_KEY_VERSION CURRENT_KEY_VERSION CURRENT_KEY_ID
12+
test/t1 1 1 1 1
13+
test/t2 1 1 1 2
14+
DROP TABLE t1, t2;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--loose-innodb-tablespaces-encryption
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- source include/have_innodb.inc
2+
-- source include/have_file_key_management_plugin.inc
3+
4+
--disable_query_log
5+
let $innodb_file_format_orig = `SELECT @@innodb_file_format`;
6+
let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`;
7+
--enable_query_log
8+
9+
SET GLOBAL innodb_file_format = `Barracuda`;
10+
SET GLOBAL innodb_file_per_table = ON;
11+
12+
CREATE TABLE t1 (c VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=1;
13+
CREATE TABLE t2 (c VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=2;
14+
INSERT INTO t1 VALUES ('foobar');
15+
INSERT INTO t2 VALUES ('foobar');
16+
17+
#
18+
# MDEV-9640: Add used key_id to INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION
19+
#
20+
SELECT NAME, ENCRYPTION_SCHEME, MIN_KEY_VERSION, CURRENT_KEY_VERSION,
21+
CURRENT_KEY_ID
22+
FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION
23+
WHERE NAME LIKE '%t1' OR NAME LIKE '%t2';
24+
25+
DROP TABLE t1, t2;
26+
27+
# reset system
28+
--disable_query_log
29+
EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig;
30+
EVAL SET GLOBAL innodb_file_format = $innodb_file_format_orig;
31+
--enable_query_log

mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ space_id page_id start_lsn end_lsn
376376
Warnings:
377377
Warning 1012 InnoDB: SELECTing from INFORMATION_SCHEMA.innodb_changed_pages but the InnoDB storage engine is not installed
378378
select * from information_schema.innodb_tablespaces_encryption;
379-
SPACE NAME ENCRYPTION_SCHEME KEYSERVER_REQUESTS MIN_KEY_VERSION CURRENT_KEY_VERSION KEY_ROTATION_PAGE_NUMBER KEY_ROTATION_MAX_PAGE_NUMBER
379+
SPACE NAME ENCRYPTION_SCHEME KEYSERVER_REQUESTS MIN_KEY_VERSION CURRENT_KEY_VERSION KEY_ROTATION_PAGE_NUMBER KEY_ROTATION_MAX_PAGE_NUMBER CURRENT_KEY_ID
380380
Warnings:
381381
Warning 1012 InnoDB: SELECTing from INFORMATION_SCHEMA.innodb_tablespaces_encryption but the InnoDB storage engine is not installed
382382
select * from information_schema.innodb_tablespaces_scrubbing;

storage/innobase/fil/fil0crypt.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
Copyright (C) 2013, 2015, Google Inc. All Rights Reserved.
3-
Copyright (C) 2014, 2015, MariaDB Corporation. All Rights Reserved.
3+
Copyright (C) 2014, 2016, MariaDB Corporation. All Rights Reserved.
44
55
This program is free software; you can redistribute it and/or modify it under
66
the terms of the GNU General Public License as published by the Free Software
@@ -2522,6 +2522,7 @@ fil_space_crypt_get_status(
25222522
mutex_enter(&crypt_data->mutex);
25232523
status->keyserver_requests = crypt_data->keyserver_requests;
25242524
status->min_key_version = crypt_data->min_key_version;
2525+
status->key_id = crypt_data->key_id;
25252526

25262527
if (crypt_data->rotate_state.active_threads > 0 ||
25272528
crypt_data->rotate_state.flushing) {

storage/innobase/handler/i_s.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2007, 2015, Oracle and/or its affiliates.
4-
Copyrigth (c) 2014, 2015, MariaDB Corporation
4+
Copyrigth (c) 2014, 2016, MariaDB Corporation
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -8134,6 +8134,15 @@ static ST_FIELD_INFO innodb_tablespaces_encryption_fields_info[] =
81348134
STRUCT_FLD(old_name, ""),
81358135
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
81368136

8137+
#define TABLESPACES_ENCRYPTION_CURRENT_KEY_ID 8
8138+
{STRUCT_FLD(field_name, "CURRENT_KEY_ID"),
8139+
STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS),
8140+
STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
8141+
STRUCT_FLD(value, 0),
8142+
STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
8143+
STRUCT_FLD(old_name, ""),
8144+
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
8145+
81378146
END_OF_ST_FIELD_INFO
81388147
};
81398148

@@ -8172,6 +8181,8 @@ i_s_dict_fill_tablespaces_encryption(
81728181
status.min_key_version));
81738182
OK(fields[TABLESPACES_ENCRYPTION_CURRENT_KEY_VERSION]->store(
81748183
status.current_key_version));
8184+
OK(fields[TABLESPACES_ENCRYPTION_CURRENT_KEY_ID]->store(
8185+
status.key_id));
81758186
if (status.rotating) {
81768187
fields[TABLESPACES_ENCRYPTION_KEY_ROTATION_PAGE_NUMBER]->set_notnull();
81778188
OK(fields[TABLESPACES_ENCRYPTION_KEY_ROTATION_PAGE_NUMBER]->store(

storage/innobase/include/fil0crypt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ struct fil_space_crypt_status_t {
333333
uint min_key_version; /*!< min key version */
334334
uint current_key_version;/*!< current key version */
335335
uint keyserver_requests;/*!< no of key requests to key server */
336+
ulint key_id; /*!< current key_id */
336337
bool rotating; /*!< is key rotation ongoing */
337338
bool flushing; /*!< is flush at end of rotation ongoing */
338339
ulint rotate_next_page_number; /*!< next page if key rotating */

storage/xtradb/fil/fil0crypt.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
Copyright (C) 2013, 2015, Google Inc. All Rights Reserved.
3-
Copyright (C) 2014, 2015, MariaDB Corporation. All Rights Reserved.
3+
Copyright (C) 2014, 2016, MariaDB Corporation. All Rights Reserved.
44
55
This program is free software; you can redistribute it and/or modify it under
66
the terms of the GNU General Public License as published by the Free Software
@@ -2522,6 +2522,7 @@ fil_space_crypt_get_status(
25222522
mutex_enter(&crypt_data->mutex);
25232523
status->keyserver_requests = crypt_data->keyserver_requests;
25242524
status->min_key_version = crypt_data->min_key_version;
2525+
status->key_id = crypt_data->key_id;
25252526

25262527
if (crypt_data->rotate_state.active_threads > 0 ||
25272528
crypt_data->rotate_state.flushing) {

storage/xtradb/handler/ha_innodb.cc

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/*****************************************************************************
22

33
Copyright (c) 2000, 2015, Oracle and/or its affiliates.
4-
Copyright (c) 2013, 2015, MariaDB Corporation.
4+
Copyright (c) 2013, 2016, MariaDB Corporation.
55
Copyright (c) 2008, 2009 Google Inc.
66
Copyright (c) 2009, Percona Inc.
77
Copyright (c) 2012, Facebook Inc.
8-
Copyright (c) 2013, 2014 SkySQL Ab. All Rights Reserved.
98

109
Portions of this file contain modifications contributed and copyrighted by
1110
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -8317,7 +8316,7 @@ ha_innobase::write_row(
83178316

83188317
if (share->ib_table != prebuilt->table) {
83198318
fprintf(stderr,
8320-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
8319+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
83218320
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
83228321
}
83238322

@@ -8670,7 +8669,7 @@ ha_innobase::write_row(
86708669

86718670
if (share->ib_table != prebuilt->table) {
86728671
fprintf(stderr,
8673-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
8672+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
86748673
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
86758674
}
86768675

@@ -9090,7 +9089,7 @@ ha_innobase::update_row(
90909089

90919090
if (share->ib_table != prebuilt->table) {
90929091
fprintf(stderr,
9093-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
9092+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
90949093
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
90959094
}
90969095

@@ -9211,7 +9210,7 @@ ha_innobase::update_row(
92119210

92129211
if (share->ib_table != prebuilt->table) {
92139212
fprintf(stderr,
9214-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
9213+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
92159214
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
92169215
}
92179216

@@ -12739,7 +12738,7 @@ ha_innobase::truncate()
1273912738

1274012739
if (share->ib_table != prebuilt->table) {
1274112740
fprintf(stderr,
12742-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
12741+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
1274312742
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
1274412743
}
1274512744

@@ -12760,7 +12759,7 @@ ha_innobase::truncate()
1276012759

1276112760
if (share->ib_table != prebuilt->table) {
1276212761
fprintf(stderr,
12763-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
12762+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
1276412763
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
1276512764
}
1276612765

@@ -14156,7 +14155,7 @@ ha_innobase::analyze(
1415614155

1415714156
if (share->ib_table != prebuilt->table) {
1415814157
fprintf(stderr,
14159-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
14158+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
1416014159
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
1416114160
}
1416214161

@@ -14172,7 +14171,7 @@ ha_innobase::analyze(
1417214171

1417314172
if (share->ib_table != prebuilt->table) {
1417414173
fprintf(stderr,
14175-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
14174+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
1417614175
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
1417714176
}
1417814177

@@ -15387,7 +15386,7 @@ ha_innobase::transactional_table_lock(
1538715386

1538815387
if (share->ib_table != prebuilt->table) {
1538915388
fprintf(stderr,
15390-
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %d.",
15389+
"InnoDB: Warning: share->ib_table %p prebuilt->table %p table %s is_corrupt %lu.",
1539115390
share->ib_table, prebuilt->table, prebuilt->table->name, prebuilt->table->is_corrupt);
1539215391
}
1539315392

0 commit comments

Comments
 (0)