summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/my_base.h4
-rw-r--r--include/my_handler_errors.h3
-rw-r--r--mysql-test/suite/encryption/r/innodb-bad-key-change.result78
-rw-r--r--mysql-test/suite/encryption/r/innodb-bad-key-change2.result16
-rw-r--r--mysql-test/suite/encryption/t/innodb-bad-key-change.test24
-rw-r--r--mysql-test/suite/encryption/t/innodb-bad-key-change2.test8
-rw-r--r--storage/innobase/btr/btr0btr.cc2
-rw-r--r--storage/innobase/btr/btr0cur.cc16
-rw-r--r--storage/innobase/buf/buf0buf.cc12
-rw-r--r--storage/innobase/dict/dict0dict.cc22
-rw-r--r--storage/innobase/handler/ha_innodb.cc22
-rw-r--r--storage/innobase/handler/handler0alter.cc11
-rw-r--r--storage/innobase/include/db0err.h4
-rw-r--r--storage/innobase/row/row0ins.cc4
-rw-r--r--storage/innobase/row/row0merge.cc6
-rw-r--r--storage/innobase/row/row0mysql.cc16
-rw-r--r--storage/innobase/row/row0sel.cc8
-rw-r--r--storage/innobase/ut/ut0ut.cc2
-rw-r--r--storage/xtradb/btr/btr0btr.cc2
-rw-r--r--storage/xtradb/btr/btr0cur.cc16
-rw-r--r--storage/xtradb/buf/buf0buf.cc16
-rw-r--r--storage/xtradb/dict/dict0dict.cc22
-rw-r--r--storage/xtradb/handler/ha_innodb.cc22
-rw-r--r--storage/xtradb/handler/handler0alter.cc11
-rw-r--r--storage/xtradb/include/db0err.h4
-rw-r--r--storage/xtradb/row/row0ins.cc4
-rw-r--r--storage/xtradb/row/row0merge.cc6
-rw-r--r--storage/xtradb/row/row0mysql.cc16
-rw-r--r--storage/xtradb/row/row0sel.cc8
-rw-r--r--storage/xtradb/ut/ut0ut.cc2
30 files changed, 244 insertions, 143 deletions
diff --git a/include/my_base.h b/include/my_base.h
index a52ad51485e..91a26f316a7 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -501,7 +501,9 @@ enum ha_base_keytype {
#define HA_ERR_DISK_FULL 189
#define HA_ERR_INCOMPATIBLE_DEFINITION 190
#define HA_ERR_FTS_TOO_MANY_WORDS_IN_PHRASE 191 /* Too many words in a phrase */
-#define HA_ERR_LAST 191 /* Copy of last error nr */
+#define HA_ERR_DECRYPTION_FAILED 192 /* Table encrypted but
+ decypt failed */
+#define HA_ERR_LAST 192 /* Copy of last error nr */
/* Number of different errors */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
diff --git a/include/my_handler_errors.h b/include/my_handler_errors.h
index a7afcfe93a3..5af6a359348 100644
--- a/include/my_handler_errors.h
+++ b/include/my_handler_errors.h
@@ -94,7 +94,8 @@ static const char *handler_error_messages[]=
"Operation was interrupted by end user (probably kill command?)",
"Disk full",
"Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump and restore the table to fix this",
- "Too many words in a FTS phrase or proximity search"
+ "Too many words in a FTS phrase or proximity search",
+ "Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match."
};
#endif /* MYSYS_MY_HANDLER_ERRORS_INCLUDED */
diff --git a/mysql-test/suite/encryption/r/innodb-bad-key-change.result b/mysql-test/suite/encryption/r/innodb-bad-key-change.result
index 6bd3c2fd77e..1026e0e62ab 100644
--- a/mysql-test/suite/encryption/r/innodb-bad-key-change.result
+++ b/mysql-test/suite/encryption/r/innodb-bad-key-change.result
@@ -7,7 +7,7 @@ call mtr.add_suppression("InnoDB: Marking tablespace as missing. You may drop th
call mtr.add_suppression(".*InnoDB: Cannot open table test/.* from the internal data dictionary of InnoDB though the .frm file for the table exists. See .* for how you can resolve the problem.");
call mtr.add_suppression("InnoDB: .ibd file is missing for table test/.*");
call mtr.add_suppression("mysqld: File .*");
-call mtr.add_suppression("InnoDB: Tablespace id 6 is encrypted but encryption service or used key_id .* is not available. Can't continue opening tablespace.");
+call mtr.add_suppression("InnoDB: Tablespace id .* is encrypted but encryption service or used key_id .* is not available. Can't continue opening tablespace.");
# Start server with keys2.txt
SET GLOBAL innodb_file_format = `Barracuda`;
@@ -33,12 +33,12 @@ foobar 2
# Restart server with keysbad3.txt
SELECT * FROM t1;
-ERROR 42S02: Table 'test.t1' doesn't exist in engine
+ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
SHOW WARNINGS;
Level Code Message
Warning 1812 Tablespace is missing for table 'test/t1'
-Warning 155 Table test/t1 is encrypted but encryption service or used key_id 2 is not available. Can't continue reading table.
-Error 1932 Table 'test.t1' doesn't exist in engine
+Warning 192 Table test/t1 is encrypted but encryption service or used key_id 2 is not available. Can't continue reading table.
+Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
DROP TABLE t1;
# Start server with keys.txt
CREATE TABLE t2 (c VARCHAR(8), id int not null primary key, b int, key(b)) ENGINE=InnoDB ENCRYPTED=YES;
@@ -46,90 +46,90 @@ INSERT INTO t2 VALUES ('foobar',1,2);
# Restart server with keys2.txt
SELECT * FROM t2;
-Got one of the listed errors
+ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
SHOW WARNINGS;
Level Code Message
-Warning 155 Table test/t2 in tablespace 7 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
-Warning 155 Table test/t2 in tablespace 7 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
-Warning 155 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
-Error 1932 Table 'test.t2' doesn't exist in engine
+Warning 192 Table test/t2 in tablespace 7 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
+Warning 192 Table test/t2 in tablespace 7 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
+Warning 192 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
+Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
SELECT * FROM t2 where id = 1;
-Got one of the listed errors
+ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
SHOW WARNINGS;
Level Code Message
Warning 1812 Tablespace is missing for table 'test/t2'
-Warning 155 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
-Error 1932 Table 'test.t2' doesn't exist in engine
+Warning 192 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
+Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
SELECT * FROM t2 where b = 1;
-Got one of the listed errors
+ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
SHOW WARNINGS;
Level Code Message
Warning 1812 Tablespace is missing for table 'test/t2'
-Warning 155 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
-Error 1932 Table 'test.t2' doesn't exist in engine
+Warning 192 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
+Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
INSERT INTO t2 VALUES ('tmp',3,3);
-ERROR 42S02: Table 'test.t2' doesn't exist in engine
+ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
SHOW WARNINGS;
Level Code Message
Warning 1812 Tablespace is missing for table 'test/t2'
-Warning 155 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
-Error 1932 Table 'test.t2' doesn't exist in engine
+Warning 192 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
+Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
DELETE FROM t2 where b = 3;
-Got one of the listed errors
+ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
SHOW WARNINGS;
Level Code Message
Warning 1812 Tablespace is missing for table 'test/t2'
-Warning 155 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
-Error 1932 Table 'test.t2' doesn't exist in engine
+Warning 192 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
+Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
DELETE FROM t2 where id = 3;
-Got one of the listed errors
+ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
SHOW WARNINGS;
Level Code Message
Warning 1812 Tablespace is missing for table 'test/t2'
-Warning 155 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
-Error 1932 Table 'test.t2' doesn't exist in engine
+Warning 192 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
+Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
UPDATE t2 set b = b +1;
-Got one of the listed errors
+ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
SHOW WARNINGS;
Level Code Message
Warning 1812 Tablespace is missing for table 'test/t2'
-Warning 155 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
-Error 1932 Table 'test.t2' doesn't exist in engine
+Warning 192 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
+Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
OPTIMIZE TABLE t2;
Table Op Msg_type Msg_text
test.t2 optimize Warning Tablespace is missing for table 'test/t2'
test.t2 optimize Warning Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
-test.t2 optimize Error Table 'test.t2' doesn't exist in engine
-test.t2 optimize status Operation failed
+test.t2 optimize Error Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
+test.t2 optimize error Corrupt
SHOW WARNINGS;
Level Code Message
ALTER TABLE t2 ADD COLUMN c INT;
-ERROR 42S02: Table 'test.t2' doesn't exist in engine
+ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
SHOW WARNINGS;
Level Code Message
Warning 1812 Tablespace is missing for table 'test/t2'
-Warning 155 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
-Error 1932 Table 'test.t2' doesn't exist in engine
+Warning 192 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
+Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
ANALYZE TABLE t2;
Table Op Msg_type Msg_text
test.t2 analyze Warning Tablespace is missing for table 'test/t2'
test.t2 analyze Warning Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
-test.t2 analyze Error Table 'test.t2' doesn't exist in engine
-test.t2 analyze status Operation failed
+test.t2 analyze Error Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
+test.t2 analyze error Corrupt
SHOW WARNINGS;
Level Code Message
TRUNCATE TABLE t2;
-ERROR 42S02: Table 'test.t2' doesn't exist in engine
+ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
SHOW WARNINGS;
Level Code Message
Warning 1812 Tablespace is missing for table 'test/t2'
-Warning 155 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
-Error 1932 Table 'test.t2' doesn't exist in engine
+Warning 192 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
+Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
DROP TABLE t2;
-ERROR HY000: Table 't2' is read only
+ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
SHOW WARNINGS;
Level Code Message
-Error 1036 Table 't2' is read only
+Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
# Restart server with keys.txt
DROP TABLE t2;
diff --git a/mysql-test/suite/encryption/r/innodb-bad-key-change2.result b/mysql-test/suite/encryption/r/innodb-bad-key-change2.result
index 314cb127ac4..ea760e7a213 100644
--- a/mysql-test/suite/encryption/r/innodb-bad-key-change2.result
+++ b/mysql-test/suite/encryption/r/innodb-bad-key-change2.result
@@ -7,10 +7,20 @@ call mtr.add_suppression("Couldn't load plugins from 'file_key_management*");
CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB ENCRYPTION_KEY_ID=4;
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
select * from t1;
+ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
+show warnings;
+Level Code Message
+Warning 192 Table test/t1 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
+Warning 192 Table test/t1 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
+Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
alter table t1 discard tablespace;
+ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
+show warnings;
+Level Code Message
+Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
alter table t1 engine=InnoDB;
-ERROR 42S02: Table 'test.t1' doesn't exist in engine
+ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
show warnings;
Level Code Message
-Warning 155 Table test/t1 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
-Error 1932 Table 'test.t1' doesn't exist in engine
+Warning 192 Table test/t1 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
+Error 1296 Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
diff --git a/mysql-test/suite/encryption/t/innodb-bad-key-change.test b/mysql-test/suite/encryption/t/innodb-bad-key-change.test
index 0787587e31a..8ef773d769b 100644
--- a/mysql-test/suite/encryption/t/innodb-bad-key-change.test
+++ b/mysql-test/suite/encryption/t/innodb-bad-key-change.test
@@ -21,7 +21,7 @@ call mtr.add_suppression("InnoDB: Marking tablespace as missing. You may drop th
call mtr.add_suppression(".*InnoDB: Cannot open table test/.* from the internal data dictionary of InnoDB though the .frm file for the table exists. See .* for how you can resolve the problem.");
call mtr.add_suppression("InnoDB: .ibd file is missing for table test/.*");
call mtr.add_suppression("mysqld: File .*");
-call mtr.add_suppression("InnoDB: Tablespace id 6 is encrypted but encryption service or used key_id .* is not available. Can't continue opening tablespace.");
+call mtr.add_suppression("InnoDB: Tablespace id .* is encrypted but encryption service or used key_id .* is not available. Can't continue opening tablespace.");
--echo
--echo # Start server with keys2.txt
-- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
@@ -52,7 +52,7 @@ SELECT * FROM t1;
-- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keysbad3.txt
-- source include/restart_mysqld.inc
---error 1932
+--error ER_GET_ERRMSG
SELECT * FROM t1;
SHOW WARNINGS;
@@ -77,38 +77,38 @@ INSERT INTO t2 VALUES ('foobar',1,2);
-- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
-- source include/restart_mysqld.inc
---error 1932,1712
+--error ER_GET_ERRMSG
SELECT * FROM t2;
SHOW WARNINGS;
---error 1932,1712
+--error ER_GET_ERRMSG
SELECT * FROM t2 where id = 1;
SHOW WARNINGS;
---error 1932,1712
+--error ER_GET_ERRMSG
SELECT * FROM t2 where b = 1;
SHOW WARNINGS;
---error 1932
+--error ER_GET_ERRMSG
INSERT INTO t2 VALUES ('tmp',3,3);
SHOW WARNINGS;
---error 1932,1712
+--error ER_GET_ERRMSG
DELETE FROM t2 where b = 3;
SHOW WARNINGS;
---error 1932,1712
+--error ER_GET_ERRMSG
DELETE FROM t2 where id = 3;
SHOW WARNINGS;
---error 1932,1712
+--error ER_GET_ERRMSG
UPDATE t2 set b = b +1;
SHOW WARNINGS;
OPTIMIZE TABLE t2;
SHOW WARNINGS;
---error 1932
+--error ER_GET_ERRMSG
ALTER TABLE t2 ADD COLUMN c INT;
SHOW WARNINGS;
ANALYZE TABLE t2;
SHOW WARNINGS;
---error 1932
+--error ER_GET_ERRMSG
TRUNCATE TABLE t2;
SHOW WARNINGS;
---error 1036
+--error ER_GET_ERRMSG
DROP TABLE t2;
SHOW WARNINGS;
diff --git a/mysql-test/suite/encryption/t/innodb-bad-key-change2.test b/mysql-test/suite/encryption/t/innodb-bad-key-change2.test
index 6dd3604a284..907c95e04d6 100644
--- a/mysql-test/suite/encryption/t/innodb-bad-key-change2.test
+++ b/mysql-test/suite/encryption/t/innodb-bad-key-change2.test
@@ -44,11 +44,13 @@ EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
---error 0,ER_NO_SUCH_TABLE_IN_ENGINE
+--error ER_GET_ERRMSG
select * from t1;
---error 0,ER_NO_SUCH_TABLE_IN_ENGINE
+show warnings;
+--error ER_GET_ERRMSG
alter table t1 discard tablespace;
---error ER_NO_SUCH_TABLE_IN_ENGINE
+show warnings;
+--error ER_GET_ERRMSG
alter table t1 engine=InnoDB;
show warnings;
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc
index d271dc4dd60..b764ca579cd 100644
--- a/storage/innobase/btr/btr0btr.cc
+++ b/storage/innobase/btr/btr0btr.cc
@@ -740,7 +740,7 @@ btr_root_block_get(
index->table->is_encrypted = TRUE;
index->table->corrupted = FALSE;
- ib_push_warning(index->table->thd, DB_ENCRYPTED_DECRYPT_FAILED,
+ ib_push_warning(index->table->thd, DB_DECRYPTION_FAILED,
"Table %s in tablespace %lu is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index acf9ffc45eb..5dbae5d291d 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -614,9 +614,9 @@ retry_page_get:
file, line, mtr, &err);
if (err != DB_SUCCESS) {
- if (err == DB_ENCRYPTED_DECRYPT_FAILED) {
+ if (err == DB_DECRYPTION_FAILED) {
ib_push_warning((void *)NULL,
- DB_ENCRYPTED_DECRYPT_FAILED,
+ DB_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
@@ -917,9 +917,9 @@ btr_cur_open_at_index_side_func(
RW_NO_LATCH, NULL, BUF_GET,
file, line, mtr, &err);
if (err != DB_SUCCESS) {
- if (err == DB_ENCRYPTED_DECRYPT_FAILED) {
+ if (err == DB_DECRYPTION_FAILED) {
ib_push_warning((void *)NULL,
- DB_ENCRYPTED_DECRYPT_FAILED,
+ DB_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
@@ -1074,9 +1074,9 @@ btr_cur_open_at_rnd_pos_func(
file, line, mtr, &err);
if (err != DB_SUCCESS) {
- if (err == DB_ENCRYPTED_DECRYPT_FAILED) {
+ if (err == DB_DECRYPTION_FAILED) {
ib_push_warning((void *)NULL,
- DB_ENCRYPTED_DECRYPT_FAILED,
+ DB_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
@@ -3630,9 +3630,9 @@ btr_estimate_n_rows_in_range_on_level(
__FILE__, __LINE__, &mtr, &err);
if (err != DB_SUCCESS) {
- if (err == DB_ENCRYPTED_DECRYPT_FAILED) {
+ if (err == DB_DECRYPTION_FAILED) {
ib_push_warning((void *)NULL,
- DB_ENCRYPTED_DECRYPT_FAILED,
+ DB_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index bbe93dada4f..2cadaa18b9c 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -2870,12 +2870,15 @@ loop:
ib_mutex_t* pmutex = buf_page_get_mutex(bpage);
buf_pool_mutex_enter(buf_pool);
mutex_enter(pmutex);
+ buf_block_t* block = buf_page_get_block(bpage);
buf_page_set_io_fix(bpage, BUF_IO_NONE);
+ buf_block_set_state(block, BUF_BLOCK_NOT_USED);
+ buf_block_set_state(block, BUF_BLOCK_READY_FOR_USE);
buf_pool_mutex_exit(buf_pool);
mutex_exit(pmutex);
if (err) {
- *err = DB_ENCRYPTED_DECRYPT_FAILED;
+ *err = DB_DECRYPTION_FAILED;
}
return (NULL);
}
@@ -2913,12 +2916,15 @@ loop:
ib_mutex_t* pmutex = buf_page_get_mutex(bpage);
buf_pool_mutex_enter(buf_pool);
mutex_enter(pmutex);
+ buf_block_t* block = buf_page_get_block(bpage);
buf_page_set_io_fix(bpage, BUF_IO_NONE);
+ buf_block_set_state(block, BUF_BLOCK_NOT_USED);
+ buf_block_set_state(block, BUF_BLOCK_READY_FOR_USE);
buf_pool_mutex_exit(buf_pool);
mutex_exit(pmutex);
if (err) {
- *err = DB_ENCRYPTED_DECRYPT_FAILED;
+ *err = DB_DECRYPTION_FAILED;
}
return (NULL);
}
@@ -4604,7 +4610,7 @@ corrupt:
ut_error;
}
- ib_push_warning((void *)NULL, DB_ENCRYPTED_DECRYPT_FAILED,
+ ib_push_warning((void *)NULL, DB_DECRYPTION_FAILED,
"Table in tablespace %lu encrypted."
"However key management plugin or used key_id %lu is not found or"
" used encryption algorithm or method does not match."
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index dba03785f09..b8c8cc690aa 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -1151,8 +1151,28 @@ dict_table_open_on_name(
if (table != NULL) {
- /* If table is corrupted, return NULL */
+ /* If table is encrypted return table */
if (ignore_err == DICT_ERR_IGNORE_NONE
+ && table->is_encrypted) {
+ /* Make life easy for drop table. */
+ if (table->can_be_evicted) {
+ dict_table_move_from_lru_to_non_lru(table);
+ }
+
+ if (table->can_be_evicted) {
+ dict_move_to_mru(table);
+ }
+
+ ++table->n_ref_count;
+
+ if (!dict_locked) {
+ mutex_exit(&dict_sys->mutex);
+ }
+
+ return (table);
+ }
+ /* If table is corrupted, return NULL */
+ else if (ignore_err == DICT_ERR_IGNORE_NONE
&& table->corrupted) {
/* Make life easy for drop table. */
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 25c9ab51962..177a2fcd8c9 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -1747,9 +1747,11 @@ convert_error_code_to_mysql(
case DB_TABLESPACE_DELETED:
case DB_TABLE_NOT_FOUND:
- case DB_ENCRYPTED_DECRYPT_FAILED:
return(HA_ERR_NO_SUCH_TABLE);
+ case DB_DECRYPTION_FAILED:
+ return(HA_ERR_DECRYPTION_FAILED);
+
case DB_TABLESPACE_NOT_FOUND:
return(HA_ERR_NO_SUCH_TABLE);
@@ -5641,6 +5643,7 @@ table_opened:
if (!thd_tablespace_op(thd) && no_tablespace) {
free_share(share);
my_errno = ENOENT;
+ int ret_err = HA_ERR_NO_SUCH_TABLE;
/* If table has no talespace but it has crypt data, check
is tablespace made unaccessible because encryption service
@@ -5653,25 +5656,27 @@ table_opened:
if (!encryption_key_id_exists(crypt_data->key_id)) {
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
- HA_ERR_NO_SUCH_TABLE,
+ HA_ERR_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id %u is not available. "
" Can't continue reading table.",
ib_table->name, crypt_data->key_id);
+ ret_err = HA_ERR_DECRYPTION_FAILED;
}
} else if (ib_table->is_encrypted) {
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
- HA_ERR_NO_SUCH_TABLE,
+ HA_ERR_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
ib_table->name);
+ ret_err = HA_ERR_DECRYPTION_FAILED;
}
}
dict_table_close(ib_table, FALSE, FALSE);
- DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
+ DBUG_RETURN(ret_err);
}
prebuilt = row_create_prebuilt(ib_table, table->s->stored_rec_length);
@@ -15517,8 +15522,13 @@ ha_innobase::get_error_message(
{
trx_t* trx = check_trx_exists(ha_thd());
- buf->copy(trx->detailed_error, (uint) strlen(trx->detailed_error),
- system_charset_info);
+ if (error == HA_ERR_DECRYPTION_FAILED) {
+ const char *msg = "Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.";
+ buf->copy(msg, (uint)strlen(msg), system_charset_info);
+ } else {
+ buf->copy(trx->detailed_error, (uint) strlen(trx->detailed_error),
+ system_charset_info);
+ }
return(FALSE);
}
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 3ed0067f395..2cede8cd82c 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2005, 2015, Oracle and/or its affiliates
-Copyright (c) 2013, 2015, SkySQL Ab
+Copyright (c) 2013, 2015, MariaDB Corporation. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -4179,10 +4179,13 @@ oom:
: ha_alter_info->key_info_buffer[
prebuilt->trx->error_key_num].name);
break;
- case DB_ENCRYPTED_DECRYPT_FAILED:
- my_error(ER_NO_SUCH_TABLE_IN_ENGINE, MYF(0),
- table_share->db.str, table_share->table_name.str);
+ case DB_DECRYPTION_FAILED: {
+ String str;
+ const char* engine= table_type();
+ get_error_message(HA_ERR_DECRYPTION_FAILED, &str);
+ my_error(ER_GET_ERRMSG, MYF(0), HA_ERR_DECRYPTION_FAILED, str.c_ptr(), engine);
break;
+ }
default:
my_error_innodb(error,
table_share->table_name.str,
diff --git a/storage/innobase/include/db0err.h b/storage/innobase/include/db0err.h
index 24889a9b9c5..feac81af98e 100644
--- a/storage/innobase/include/db0err.h
+++ b/storage/innobase/include/db0err.h
@@ -133,8 +133,8 @@ enum dberr_t {
/*< Too many words in a phrase */
DB_TOO_BIG_FOR_REDO, /* Record length greater than 10%
of redo log */
- DB_ENCRYPTED_DECRYPT_FAILED, /* Tablespace encrypted and
- decrypt operaton failed because
+ DB_DECRYPTION_FAILED, /* Tablespace encrypted and
+ decrypt operation failed because
of missing key management plugin,
or missing or incorrect key or
incorret AES method or algorithm. */
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index 4f891e0f114..44ffe9982e9 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -2681,9 +2681,9 @@ row_ins_sec_index_entry_low(
&cursor, 0, __FILE__, __LINE__, &mtr);
if (err != DB_SUCCESS) {
- if (err == DB_ENCRYPTED_DECRYPT_FAILED) {
+ if (err == DB_DECRYPTION_FAILED) {
ib_push_warning(trx->mysql_thd,
- DB_ENCRYPTED_DECRYPT_FAILED,
+ DB_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index b684a3592df..0669dfef34f 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -1578,7 +1578,7 @@ row_merge_read_clustered_index(
/* Do not continue if table pages are still encrypted */
if (old_table->is_encrypted || new_table->is_encrypted) {
- err = DB_ENCRYPTED_DECRYPT_FAILED;
+ err = DB_DECRYPTION_FAILED;
trx->error_key_num = 0;
goto func_exit;
}
@@ -3981,8 +3981,8 @@ row_merge_build_indexes(
/* Do not continue if we can't encrypt table pages */
if (old_table->is_encrypted || new_table->is_encrypted) {
- error = DB_ENCRYPTED_DECRYPT_FAILED;
- ib_push_warning(trx->mysql_thd, DB_ENCRYPTED_DECRYPT_FAILED,
+ error = DB_DECRYPTION_FAILED;
+ ib_push_warning(trx->mysql_thd, DB_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index d46e2b1c3ef..d609f9649fd 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -624,7 +624,7 @@ handle_new_error:
case DB_INTERRUPTED:
case DB_DICT_CHANGED:
case DB_TABLE_NOT_FOUND:
- case DB_ENCRYPTED_DECRYPT_FAILED:
+ case DB_DECRYPTION_FAILED:
if (savept) {
/* Roll back the latest, possibly incomplete insertion
or update */
@@ -1318,12 +1318,12 @@ row_insert_for_mysql(
return(DB_TABLESPACE_NOT_FOUND);
} else if (prebuilt->table->is_encrypted) {
- ib_push_warning(trx, DB_ENCRYPTED_DECRYPT_FAILED,
+ ib_push_warning(trx, DB_DECRYPTION_FAILED,
"Table %s in tablespace %lu encrypted."
"However key management plugin or used key_id is not found or"
" used encryption algorithm or method does not match.",
prebuilt->table->name, prebuilt->table->space);
- return(DB_ENCRYPTED_DECRYPT_FAILED);
+ return(DB_DECRYPTION_FAILED);
} else if (prebuilt->magic_n != ROW_PREBUILT_ALLOCATED) {
fprintf(stderr,
"InnoDB: Error: trying to free a corrupt\n"
@@ -1719,7 +1719,7 @@ row_update_for_mysql(
prebuilt->table->name);
return(DB_ERROR);
} else if (prebuilt->table->is_encrypted) {
- ib_push_warning(trx, DB_ENCRYPTED_DECRYPT_FAILED,
+ ib_push_warning(trx, DB_DECRYPTION_FAILED,
"Table %s in tablespace %lu encrypted."
"However key management plugin or used key_id is not found or"
" used encryption algorithm or method does not match.",
@@ -3139,6 +3139,8 @@ row_discard_tablespace_for_mysql(
if (table == 0) {
err = DB_TABLE_NOT_FOUND;
+ } else if (table->is_encrypted) {
+ err = DB_DECRYPTION_FAILED;
} else if (table->space == TRX_SYS_SPACE) {
char table_name[MAX_FULL_NAME_LEN + 1];
@@ -3357,6 +3359,8 @@ row_truncate_table_for_mysql(
if (dict_table_is_discarded(table)) {
return(DB_TABLESPACE_DELETED);
+ } else if (table->is_encrypted) {
+ return(DB_DECRYPTION_FAILED);
} else if (table->ibd_file_missing) {
return(DB_TABLESPACE_NOT_FOUND);
}
@@ -3935,7 +3939,7 @@ row_drop_table_for_mysql(
}
/* If table is encrypted and table page encryption failed
- mark this table read only. */
+ return error. */
if (table->is_encrypted) {
if (table->can_be_evicted) {
@@ -3943,7 +3947,7 @@ row_drop_table_for_mysql(
}
dict_table_close(table, TRUE, FALSE);
- err = DB_READ_ONLY;
+ err = DB_DECRYPTION_FAILED;
goto funct_exit;
}
diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc
index 53ec30b1f42..ea2f93dd788 100644
--- a/storage/innobase/row/row0sel.cc
+++ b/storage/innobase/row/row0sel.cc
@@ -3720,7 +3720,7 @@ row_search_for_mysql(
} else if (prebuilt->table->is_encrypted) {
- return(DB_ENCRYPTED_DECRYPT_FAILED);
+ return(DB_DECRYPTION_FAILED);
} else if (!prebuilt->index_usable) {
return(DB_MISSING_HISTORY);
@@ -4193,9 +4193,9 @@ wait_table_again:
pcur, false, 0, &mtr);
if (err != DB_SUCCESS) {
- if (err == DB_ENCRYPTED_DECRYPT_FAILED) {
+ if (err == DB_DECRYPTION_FAILED) {
ib_push_warning(trx->mysql_thd,
- DB_ENCRYPTED_DECRYPT_FAILED,
+ DB_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
@@ -4221,7 +4221,7 @@ rec_loop:
rec = btr_pcur_get_rec(pcur);
if (!rec) {
- err = DB_ENCRYPTED_DECRYPT_FAILED;
+ err = DB_DECRYPTION_FAILED;
goto lock_wait_or_error;
}
diff --git a/storage/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc
index f19737aa123..e7a22c15d16 100644
--- a/storage/innobase/ut/ut0ut.cc
+++ b/storage/innobase/ut/ut0ut.cc
@@ -824,7 +824,7 @@ ut_strerr(
return("Too many words in a FTS phrase or proximity search");
case DB_TOO_BIG_FOR_REDO:
return("BLOB record length is greater than 10%% of redo log");
- case DB_ENCRYPTED_DECRYPT_FAILED:
+ case DB_DECRYPTION_FAILED:
return("Table is encrypted but decrypt failed.");
/* do not add default: in order to produce a warning if new code
diff --git a/storage/xtradb/btr/btr0btr.cc b/storage/xtradb/btr/btr0btr.cc
index 86e70109db5..a3bca26abf1 100644
--- a/storage/xtradb/btr/btr0btr.cc
+++ b/storage/xtradb/btr/btr0btr.cc
@@ -746,7 +746,7 @@ btr_root_block_get(
index->table->is_encrypted = TRUE;
index->table->corrupted = FALSE;
- ib_push_warning(index->table->thd, DB_ENCRYPTED_DECRYPT_FAILED,
+ ib_push_warning(index->table->thd, DB_DECRYPTION_FAILED,
"Table %s in tablespace %lu is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
diff --git a/storage/xtradb/btr/btr0cur.cc b/storage/xtradb/btr/btr0cur.cc
index 316271077ae..728d14e6309 100644
--- a/storage/xtradb/btr/btr0cur.cc
+++ b/storage/xtradb/btr/btr0cur.cc
@@ -654,9 +654,9 @@ retry_page_get:
file, line, mtr, &err);
if (err != DB_SUCCESS) {
- if (err == DB_ENCRYPTED_DECRYPT_FAILED) {
+ if (err == DB_DECRYPTION_FAILED) {
ib_push_warning((void *)NULL,
- DB_ENCRYPTED_DECRYPT_FAILED,
+ DB_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
@@ -984,9 +984,9 @@ btr_cur_open_at_index_side_func(
RW_NO_LATCH, NULL, BUF_GET,
file, line, mtr, &err);
if (err != DB_SUCCESS) {
- if (err == DB_ENCRYPTED_DECRYPT_FAILED) {
+ if (err == DB_DECRYPTION_FAILED) {
ib_push_warning((void *)NULL,
- DB_ENCRYPTED_DECRYPT_FAILED,
+ DB_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
@@ -1157,9 +1157,9 @@ btr_cur_open_at_rnd_pos_func(
file, line, mtr, &err);
if (err != DB_SUCCESS) {
- if (err == DB_ENCRYPTED_DECRYPT_FAILED) {
+ if (err == DB_DECRYPTION_FAILED) {
ib_push_warning((void *)NULL,
- DB_ENCRYPTED_DECRYPT_FAILED,
+ DB_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
@@ -3815,9 +3815,9 @@ btr_estimate_n_rows_in_range_on_level(
__FILE__, __LINE__, &mtr, &err);
if (err != DB_SUCCESS) {
- if (err == DB_ENCRYPTED_DECRYPT_FAILED) {
+ if (err == DB_DECRYPTION_FAILED) {
ib_push_warning((void *)NULL,
- DB_ENCRYPTED_DECRYPT_FAILED,
+ DB_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc
index 31157aa737f..85023be9402 100644
--- a/storage/xtradb/buf/buf0buf.cc
+++ b/storage/xtradb/buf/buf0buf.cc
@@ -2911,12 +2911,15 @@ loop:
ib_mutex_t* pmutex = buf_page_get_mutex(bpage);
mutex_enter(&buf_pool->LRU_list_mutex);
mutex_enter(pmutex);
+ buf_block_t* block = buf_page_get_block(bpage);
buf_page_set_io_fix(bpage, BUF_IO_NONE);
- buf_LRU_free_page(bpage, zip_size ? true : false);
+ buf_block_set_state(block, BUF_BLOCK_NOT_USED);
+ buf_block_set_state(block, BUF_BLOCK_READY_FOR_USE);
+ mutex_exit(&buf_pool->LRU_list_mutex);
mutex_exit(pmutex);
if (err) {
- *err = DB_ENCRYPTED_DECRYPT_FAILED;
+ *err = DB_DECRYPTION_FAILED;
}
return (NULL);
}
@@ -2954,12 +2957,15 @@ loop:
ib_mutex_t* pmutex = buf_page_get_mutex(bpage);
mutex_enter(&buf_pool->LRU_list_mutex);
mutex_enter(pmutex);
+ buf_block_t* block = buf_page_get_block(bpage);
buf_page_set_io_fix(bpage, BUF_IO_NONE);
- buf_LRU_free_page(bpage, zip_size ? true : false);
+ buf_block_set_state(block, BUF_BLOCK_NOT_USED);
+ buf_block_set_state(block, BUF_BLOCK_READY_FOR_USE);
+ mutex_exit(&buf_pool->LRU_list_mutex);
mutex_exit(pmutex);
if (err) {
- *err = DB_ENCRYPTED_DECRYPT_FAILED;
+ *err = DB_DECRYPTION_FAILED;
}
return (NULL);
}
@@ -4721,7 +4727,7 @@ corrupt:
ut_error;
}
- ib_push_warning(innobase_get_trx(), DB_ENCRYPTED_DECRYPT_FAILED,
+ ib_push_warning(innobase_get_trx(), DB_DECRYPTION_FAILED,
"Table in tablespace %lu encrypted."
"However key management plugin or used key_id %lu is not found or"
" used encryption algorithm or method does not match."
diff --git a/storage/xtradb/dict/dict0dict.cc b/storage/xtradb/dict/dict0dict.cc
index 0e1906a1827..8738e2bbf9e 100644
--- a/storage/xtradb/dict/dict0dict.cc
+++ b/storage/xtradb/dict/dict0dict.cc
@@ -1151,8 +1151,28 @@ dict_table_open_on_name(
if (table != NULL) {
- /* If table is corrupted, return NULL */
+ /* If table is encrypted return table */
if (ignore_err == DICT_ERR_IGNORE_NONE
+ && table->is_encrypted) {
+ /* Make life easy for drop table. */
+ if (table->can_be_evicted) {
+ dict_table_move_from_lru_to_non_lru(table);
+ }
+
+ if (table->can_be_evicted) {
+ dict_move_to_mru(table);
+ }
+
+ ++table->n_ref_count;
+
+ if (!dict_locked) {
+ mutex_exit(&dict_sys->mutex);
+ }
+
+ return (table);
+ }
+ /* If table is corrupted, return NULL */
+ else if (ignore_err == DICT_ERR_IGNORE_NONE
&& table->corrupted) {
/* Make life easy for drop table. */
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 78e7f5c35ac..2d014611837 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -2006,9 +2006,11 @@ convert_error_code_to_mysql(
case DB_TABLESPACE_DELETED:
case DB_TABLE_NOT_FOUND:
- case DB_ENCRYPTED_DECRYPT_FAILED:
return(HA_ERR_NO_SUCH_TABLE);
+ case DB_DECRYPTION_FAILED:
+ return(HA_ERR_DECRYPTION_FAILED);
+
case DB_TABLESPACE_NOT_FOUND:
return(HA_ERR_NO_SUCH_TABLE);
@@ -6092,6 +6094,7 @@ table_opened:
if (!thd_tablespace_op(thd) && no_tablespace) {
free_share(share);
my_errno = ENOENT;
+ int ret_err = HA_ERR_NO_SUCH_TABLE;
/* If table has no talespace but it has crypt data, check
is tablespace made unaccessible because encryption service
@@ -6104,25 +6107,27 @@ table_opened:
if (!encryption_key_id_exists(crypt_data->key_id)) {
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
- HA_ERR_NO_SUCH_TABLE,
+ HA_ERR_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id %u is not available. "
" Can't continue reading table.",
ib_table->name, crypt_data->key_id);
+ ret_err = HA_ERR_DECRYPTION_FAILED;
}
} else if (ib_table->is_encrypted) {
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
- HA_ERR_NO_SUCH_TABLE,
+ HA_ERR_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
ib_table->name);
+ ret_err = HA_ERR_DECRYPTION_FAILED;
}
}
dict_table_close(ib_table, FALSE, FALSE);
- DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
+ DBUG_RETURN(ret_err);
}
prebuilt = row_create_prebuilt(ib_table, table->s->stored_rec_length);
@@ -16071,8 +16076,13 @@ ha_innobase::get_error_message(
{
trx_t* trx = check_trx_exists(ha_thd());
- buf->copy(trx->detailed_error, (uint) strlen(trx->detailed_error),
- system_charset_info);
+ if (error == HA_ERR_DECRYPTION_FAILED) {
+ const char *msg = "Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.";
+ buf->copy(msg, (uint)strlen(msg), system_charset_info);
+ } else {
+ buf->copy(trx->detailed_error, (uint) strlen(trx->detailed_error),
+ system_charset_info);
+ }
return(FALSE);
}
diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc
index 5a190e4ca9a..c47b0f499de 100644
--- a/storage/xtradb/handler/handler0alter.cc
+++ b/storage/xtradb/handler/handler0alter.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2005, 2014, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2013, 2014, SkySQL Ab. All Rights Reserved.
+Copyright (c) 2013, 2015, MariaDB Corporation. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -4168,10 +4168,13 @@ oom:
: ha_alter_info->key_info_buffer[
prebuilt->trx->error_key_num].name);
break;
- case DB_ENCRYPTED_DECRYPT_FAILED:
- my_error(ER_NO_SUCH_TABLE_IN_ENGINE, MYF(0),
- table_share->db.str, table_share->table_name.str);
+ case DB_DECRYPTION_FAILED: {
+ String str;
+ const char* engine= table_type();
+ get_error_message(HA_ERR_DECRYPTION_FAILED, &str);
+ my_error(ER_GET_ERRMSG, MYF(0), HA_ERR_DECRYPTION_FAILED, str.c_ptr(), engine);
break;
+ }
default:
my_error_innodb(error,
table_share->table_name.str,
diff --git a/storage/xtradb/include/db0err.h b/storage/xtradb/include/db0err.h
index bb206dde72b..b11c5f4ea1a 100644
--- a/storage/xtradb/include/db0err.h
+++ b/storage/xtradb/include/db0err.h
@@ -133,8 +133,8 @@ enum dberr_t {
/*< Too many words in a phrase */
DB_TOO_BIG_FOR_REDO, /* Record length greater than 10%
of redo log */
- DB_ENCRYPTED_DECRYPT_FAILED, /* Tablespace encrypted and
- decrypt operaton failed because
+ DB_DECRYPTION_FAILED, /* Tablespace encrypted and
+ decrypt operation failed because
of missing key management plugin,
or missing or incorrect key or
incorret AES method or algorithm. */
diff --git a/storage/xtradb/row/row0ins.cc b/storage/xtradb/row/row0ins.cc
index 3f22a7d422d..ae63f0c323b 100644
--- a/storage/xtradb/row/row0ins.cc
+++ b/storage/xtradb/row/row0ins.cc
@@ -2708,9 +2708,9 @@ row_ins_sec_index_entry_low(
&cursor, 0, __FILE__, __LINE__, &mtr);
if (err != DB_SUCCESS) {
- if (err == DB_ENCRYPTED_DECRYPT_FAILED) {
+ if (err == DB_DECRYPTION_FAILED) {
ib_push_warning(trx->mysql_thd,
- DB_ENCRYPTED_DECRYPT_FAILED,
+ DB_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc
index 2f2be12c6f8..7b8787808d9 100644
--- a/storage/xtradb/row/row0merge.cc
+++ b/storage/xtradb/row/row0merge.cc
@@ -1580,7 +1580,7 @@ row_merge_read_clustered_index(
/* Do not continue if table pages are still encrypted */
if (old_table->is_encrypted || new_table->is_encrypted) {
- err = DB_ENCRYPTED_DECRYPT_FAILED;
+ err = DB_DECRYPTION_FAILED;
trx->error_key_num = 0;
goto func_exit;
}
@@ -3989,8 +3989,8 @@ row_merge_build_indexes(
/* Do not continue if we can't encrypt table pages */
if (old_table->is_encrypted || new_table->is_encrypted) {
- error = DB_ENCRYPTED_DECRYPT_FAILED;
- ib_push_warning(trx->mysql_thd, DB_ENCRYPTED_DECRYPT_FAILED,
+ error = DB_DECRYPTION_FAILED;
+ ib_push_warning(trx->mysql_thd, DB_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
diff --git a/storage/xtradb/row/row0mysql.cc b/storage/xtradb/row/row0mysql.cc
index 64c6783f1e4..592c0baf552 100644
--- a/storage/xtradb/row/row0mysql.cc
+++ b/storage/xtradb/row/row0mysql.cc
@@ -623,7 +623,7 @@ handle_new_error:
case DB_INTERRUPTED:
case DB_DICT_CHANGED:
case DB_TABLE_NOT_FOUND:
- case DB_ENCRYPTED_DECRYPT_FAILED:
+ case DB_DECRYPTION_FAILED:
if (savept) {
/* Roll back the latest, possibly incomplete insertion
or update */
@@ -1317,12 +1317,12 @@ row_insert_for_mysql(
return(DB_TABLESPACE_NOT_FOUND);
} else if (prebuilt->table->is_encrypted) {
- ib_push_warning(trx, DB_ENCRYPTED_DECRYPT_FAILED,
+ ib_push_warning(trx, DB_DECRYPTION_FAILED,
"Table %s in tablespace %lu encrypted."
"However key management plugin or used key_id is not found or"
" used encryption algorithm or method does not match.",
prebuilt->table->name, prebuilt->table->space);
- return(DB_ENCRYPTED_DECRYPT_FAILED);
+ return(DB_DECRYPTION_FAILED);
} else if (prebuilt->magic_n != ROW_PREBUILT_ALLOCATED) {
fprintf(stderr,
"InnoDB: Error: trying to free a corrupt\n"
@@ -1722,7 +1722,7 @@ row_update_for_mysql(
prebuilt->table->name);
return(DB_ERROR);
} else if (prebuilt->table->is_encrypted) {
- ib_push_warning(trx, DB_ENCRYPTED_DECRYPT_FAILED,
+ ib_push_warning(trx, DB_DECRYPTION_FAILED,
"Table %s in tablespace %lu encrypted."
"However key management plugin or used key_id is not found or"
" used encryption algorithm or method does not match.",
@@ -3152,6 +3152,8 @@ row_discard_tablespace_for_mysql(
if (table == 0) {
err = DB_TABLE_NOT_FOUND;
+ } else if (table->is_encrypted) {
+ err = DB_DECRYPTION_FAILED;
} else if (table->space == TRX_SYS_SPACE) {
char table_name[MAX_FULL_NAME_LEN + 1];
@@ -3370,6 +3372,8 @@ row_truncate_table_for_mysql(
if (dict_table_is_discarded(table)) {
return(DB_TABLESPACE_DELETED);
+ } else if (table->is_encrypted) {
+ return(DB_DECRYPTION_FAILED);
} else if (table->ibd_file_missing) {
return(DB_TABLESPACE_NOT_FOUND);
}
@@ -3948,7 +3952,7 @@ row_drop_table_for_mysql(
}
/* If table is encrypted and table page encryption failed
- mark this table read only. */
+ return error. */
if (table->is_encrypted) {
if (table->can_be_evicted) {
@@ -3956,7 +3960,7 @@ row_drop_table_for_mysql(
}
dict_table_close(table, TRUE, FALSE);
- err = DB_READ_ONLY;
+ err = DB_DECRYPTION_FAILED;
goto funct_exit;
}
diff --git a/storage/xtradb/row/row0sel.cc b/storage/xtradb/row/row0sel.cc
index a1edbca757c..0be97e12e0a 100644
--- a/storage/xtradb/row/row0sel.cc
+++ b/storage/xtradb/row/row0sel.cc
@@ -3729,7 +3729,7 @@ row_search_for_mysql(
} else if (prebuilt->table->is_encrypted) {
- return(DB_ENCRYPTED_DECRYPT_FAILED);
+ return(DB_DECRYPTION_FAILED);
} else if (!prebuilt->index_usable) {
return(DB_MISSING_HISTORY);
@@ -4187,9 +4187,9 @@ wait_table_again:
pcur, false, 0, &mtr);
if (err != DB_SUCCESS) {
- if (err == DB_ENCRYPTED_DECRYPT_FAILED) {
+ if (err == DB_DECRYPTION_FAILED) {
ib_push_warning(trx->mysql_thd,
- DB_ENCRYPTED_DECRYPT_FAILED,
+ DB_DECRYPTION_FAILED,
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
@@ -4215,7 +4215,7 @@ rec_loop:
rec = btr_pcur_get_rec(pcur);
if (!rec) {
- err = DB_ENCRYPTED_DECRYPT_FAILED;
+ err = DB_DECRYPTION_FAILED;
goto lock_wait_or_error;
}
diff --git a/storage/xtradb/ut/ut0ut.cc b/storage/xtradb/ut/ut0ut.cc
index 96f2c537deb..7a8c0b053d4 100644
--- a/storage/xtradb/ut/ut0ut.cc
+++ b/storage/xtradb/ut/ut0ut.cc
@@ -827,7 +827,7 @@ ut_strerr(
return("Too many words in a FTS phrase or proximity search");
case DB_TOO_BIG_FOR_REDO:
return("BLOB record length is greater than 10%% of redo log");
- case DB_ENCRYPTED_DECRYPT_FAILED:
+ case DB_DECRYPTION_FAILED:
return("Table is encrypted but decrypt failed.");
/* do not add default: in order to produce a warning if new code