summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-04-05 11:41:03 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-04-05 11:41:03 +0300
commit02d9b048a2ab549a3227a81e15ff2f8c45562a65 (patch)
tree63501637d9f13946439b069611f0db6e806744c4
parent5da6944ea3a592efefd1adc33b1280ad1de66688 (diff)
parentd5a2bc6a0f24f2a9ec73a0d18bb7e6fba3496bed (diff)
downloadmariadb-git-02d9b048a2ab549a3227a81e15ff2f8c45562a65.tar.gz
Merge 10.3 into 10.4
-rw-r--r--mysql-test/include/check-testcase.test2
-rw-r--r--mysql-test/suite/encryption/r/innodb-bad-key-change.result3
-rw-r--r--mysql-test/suite/encryption/r/innodb-bad-key-change2.result9
-rw-r--r--mysql-test/suite/encryption/r/innodb-bad-key-change4.result2
-rw-r--r--mysql-test/suite/encryption/r/innodb-compressed-blob.result5
-rw-r--r--mysql-test/suite/encryption/r/innodb-encryption-disable.result1
-rw-r--r--mysql-test/suite/encryption/r/innodb-force-corrupt.result1
-rw-r--r--mysql-test/suite/encryption/r/innodb-missing-key.result1
-rw-r--r--mysql-test/suite/encryption/t/innodb-bad-key-change.test1
-rw-r--r--mysql-test/suite/encryption/t/innodb-bad-key-change2.test12
-rw-r--r--mysql-test/suite/encryption/t/innodb-bad-key-change4.test1
-rw-r--r--mysql-test/suite/encryption/t/innodb-compressed-blob.test5
-rw-r--r--mysql-test/suite/encryption/t/innodb-encryption-disable.test1
-rw-r--r--mysql-test/suite/encryption/t/innodb-force-corrupt.test1
-rw-r--r--mysql-test/suite/encryption/t/innodb-missing-key.test1
-rw-r--r--mysql-test/suite/innodb/r/alter_kill.result31
-rw-r--r--mysql-test/suite/innodb/t/alter_kill.test50
-rw-r--r--mysql-test/suite/mariabackup/unencrypted_page_compressed.result2
-rw-r--r--sql/item_func.h1
-rw-r--r--storage/federatedx/ha_federatedx.h1
-rw-r--r--storage/innobase/btr/btr0btr.cc9
-rw-r--r--storage/innobase/btr/btr0cur.cc12
-rw-r--r--storage/innobase/buf/buf0buf.cc4
-rw-r--r--storage/innobase/dict/dict0load.cc107
-rw-r--r--storage/innobase/handler/ha_innodb.cc8
-rw-r--r--storage/innobase/handler/handler0alter.cc8
-rw-r--r--storage/innobase/include/dict0crea.ic14
-rw-r--r--storage/innobase/include/dict0load.h9
-rw-r--r--storage/innobase/include/dict0mem.h12
-rw-r--r--storage/innobase/include/dict0types.h8
-rw-r--r--storage/innobase/include/row0mysql.h11
-rw-r--r--storage/innobase/row/row0ins.cc2
-rw-r--r--storage/innobase/row/row0mysql.cc25
-rw-r--r--storage/innobase/row/row0sel.cc2
-rw-r--r--storage/innobase/srv/srv0start.cc15
35 files changed, 159 insertions, 218 deletions
diff --git a/mysql-test/include/check-testcase.test b/mysql-test/include/check-testcase.test
index 39aa3d49d68..191feae1628 100644
--- a/mysql-test/include/check-testcase.test
+++ b/mysql-test/include/check-testcase.test
@@ -98,7 +98,7 @@ call mtr.check_testcase();
let $datadir=`select @@datadir`;
list_files $datadir mysql_upgrade_info;
list_files_write_file $datadir.tempfiles.txt $datadir/test #sql*;
---replace_regex /#sql-ib[0-9a-f]+-[0-9a-f]+\.ibd\n//
+--replace_regex /#sql-ib[0-9a-f]+\.ibd\n//
cat_file $datadir.tempfiles.txt;
remove_file $datadir.tempfiles.txt;
list_files $datadir/mysql #sql*;
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 6ddfc0a79b7..45c32317557 100644
--- a/mysql-test/suite/encryption/r/innodb-bad-key-change.result
+++ b/mysql-test/suite/encryption/r/innodb-bad-key-change.result
@@ -4,6 +4,7 @@ call mtr.add_suppression("InnoDB: Table `test`\\.`t[12]` (has an unreadable root
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[12]\\.ibd' cannot be decrypted\\.");
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=3\\] in file .*test.t1.ibd looks corrupted; key_version=1");
+call mtr.add_suppression("InnoDB: Table `test`\\.`t[12]` is corrupted");
call mtr.add_suppression("File '.*mysql-test.std_data.keysbad3\\.txt' not found");
# Start server with keys2.txt
# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt
@@ -33,8 +34,6 @@ SELECT * FROM t1;
ERROR 42S02: Table 'test.t1' doesn't exist in engine
# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keysbad3.txt
DROP TABLE t1;
-Warnings:
-Warning 192 Table test/t1 in file ./test/t1.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table.
# Start server with keys3.txt
# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt
SET GLOBAL innodb_default_encryption_key_id=5;
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 4f61fff1293..78b9b7854de 100644
--- a/mysql-test/suite/encryption/r/innodb-bad-key-change2.result
+++ b/mysql-test/suite/encryption/r/innodb-bad-key-change2.result
@@ -3,6 +3,9 @@ call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page n
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
call mtr.add_suppression("Couldn't load plugins from 'file_key_management");
call mtr.add_suppression("InnoDB: Tablespace for table \`test\`.\`t1\` is set as discarded\\.");
+call mtr.add_suppression("InnoDB: Table `test`\\.`t1` is corrupted");
+call mtr.add_suppression("InnoDB: Cannot delete tablespace .* because it is not found in the tablespace memory cache");
+call mtr.add_suppression("InnoDB: ALTER TABLE `test`\\.`t1` DISCARD TABLESPACE failed to find tablespace");
# restart: --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt
SET GLOBAL innodb_file_per_table = ON;
CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB
@@ -13,7 +16,6 @@ SELECT * FROM t1;
ERROR 42S02: Table 'test.t1' doesn't exist in engine
SHOW WARNINGS;
Level Code Message
-Warning 192 Table test/t1 in file ./test/t1.ibd 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
ALTER TABLE t1 ENGINE=InnoDB;
ERROR 42S02: Table 'test.t1' doesn't exist in engine
@@ -45,9 +47,12 @@ ENCRYPTED=YES ENCRYPTION_KEY_ID=4;
ALTER TABLE t1 DISCARD TABLESPACE;
restore: t1 .ibd and .cfg files
# restart: --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt
-ALTER TABLE t1 IMPORT TABLESPACE;
+ALTER TABLE t1 DISCARD TABLESPACE;
Warnings:
Warning 1814 Tablespace has been discarded for table `t1`
+Warning 1812 Tablespace is missing for table 'test/t1'
+restore: t1 .ibd and .cfg files
+ALTER TABLE t1 IMPORT TABLESPACE;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
diff --git a/mysql-test/suite/encryption/r/innodb-bad-key-change4.result b/mysql-test/suite/encryption/r/innodb-bad-key-change4.result
index fdaa9264395..6c23f94eb47 100644
--- a/mysql-test/suite/encryption/r/innodb-bad-key-change4.result
+++ b/mysql-test/suite/encryption/r/innodb-bad-key-change4.result
@@ -2,6 +2,7 @@ call mtr.add_suppression("InnoDB: Table `test`\\.`t1` (has an unreadable root pa
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t1\\.ibd' cannot be decrypted\\.");
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
call mtr.add_suppression("Couldn't load plugins from 'file_key_management");
+call mtr.add_suppression("InnoDB: Table `test`\\.`t1` is corrupted");
# restart: --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt
SET GLOBAL innodb_file_per_table = ON;
CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB
@@ -10,7 +11,6 @@ INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
# restart: --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
-test.t1 optimize Warning Table test/t1 in file ./test/t1.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table.
test.t1 optimize Error Table 'test.t1' doesn't exist in engine
test.t1 optimize status Operation failed
SHOW WARNINGS;
diff --git a/mysql-test/suite/encryption/r/innodb-compressed-blob.result b/mysql-test/suite/encryption/r/innodb-compressed-blob.result
index 6ef9fe8bfcc..de20b554a67 100644
--- a/mysql-test/suite/encryption/r/innodb-compressed-blob.result
+++ b/mysql-test/suite/encryption/r/innodb-compressed-blob.result
@@ -1,6 +1,7 @@
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\.");
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
call mtr.add_suppression("InnoDB: Unable to decompress ..test.t[1-3]\\.ibd\\[page id: space=[1-9][0-9]*, page number=[0-9]+\\]");
+call mtr.add_suppression("InnoDB: Table `test`\\.`t[12]` is corrupted");
# Restart mysqld --file-key-management-filename=keys2.txt
# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt
SET GLOBAL innodb_file_per_table = ON;
@@ -16,9 +17,9 @@ insert into t3 values (1, repeat('secret',6000));
# Restart mysqld --file-key-management-filename=keys3.txt
# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt
select count(*) from t1 FORCE INDEX (b) where b like 'secret%';
-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
+ERROR 42S02: Table 'test.t1' doesn't exist in engine
select count(*) from t2 FORCE INDEX (b) where b like 'secret%';
-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
+ERROR 42S02: Table 'test.t2' doesn't exist in engine
select count(*) from t3 FORCE INDEX (b) where b like 'secret%';
count(*)
1
diff --git a/mysql-test/suite/encryption/r/innodb-encryption-disable.result b/mysql-test/suite/encryption/r/innodb-encryption-disable.result
index ae843a87769..e49a6b759e9 100644
--- a/mysql-test/suite/encryption/r/innodb-encryption-disable.result
+++ b/mysql-test/suite/encryption/r/innodb-encryption-disable.result
@@ -2,6 +2,7 @@ call mtr.add_suppression("InnoDB: Table `test`\\.`t[15]` (has an unreadable root
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[15]\\.ibd' cannot be decrypted\\.");
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=3\\] in file .*test.t[15].ibd looks corrupted; key_version=1");
+call mtr.add_suppression("InnoDB: Table `test`\\.`t[15]` is corrupted");
call mtr.add_suppression("Couldn't load plugins from 'file_key_management");
# restart: --innodb-encrypt-tables=ON --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt
create table t5 (
diff --git a/mysql-test/suite/encryption/r/innodb-force-corrupt.result b/mysql-test/suite/encryption/r/innodb-force-corrupt.result
index 97d5095044d..8c9f480554d 100644
--- a/mysql-test/suite/encryption/r/innodb-force-corrupt.result
+++ b/mysql-test/suite/encryption/r/innodb-force-corrupt.result
@@ -1,5 +1,6 @@
call mtr.add_suppression("InnoDB: Table `test`\\.`t[13]` (has an unreadable root page|is corrupted)");
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=\\d+, page number=[36]\\] in file .*test.t[123]\\.ibd looks corrupted; key_version=");
+call mtr.add_suppression("InnoDB: Table `test`\\.`t[13]` is corrupted");
SET GLOBAL innodb_file_per_table = ON;
set global innodb_compression_algorithm = 1;
# Create and populate tables to be corrupted
diff --git a/mysql-test/suite/encryption/r/innodb-missing-key.result b/mysql-test/suite/encryption/r/innodb-missing-key.result
index 391912a492c..ecb4ad2c40e 100644
--- a/mysql-test/suite/encryption/r/innodb-missing-key.result
+++ b/mysql-test/suite/encryption/r/innodb-missing-key.result
@@ -2,6 +2,7 @@ call mtr.add_suppression("InnoDB: Table `test`\\.`t1` (has an unreadable root pa
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\.");
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file .*test.t[12].ibd looks corrupted; key_version=1");
+call mtr.add_suppression("InnoDB: Table `test`\\.`t1` is corrupted");
# Start server with keys2.txt
# restart: --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt
CREATE TABLE t1(a int not null primary key auto_increment, b varchar(128)) engine=innodb ENCRYPTED=YES ENCRYPTION_KEY_ID=19;
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 a832880c494..552b9867d69 100644
--- a/mysql-test/suite/encryption/t/innodb-bad-key-change.test
+++ b/mysql-test/suite/encryption/t/innodb-bad-key-change.test
@@ -14,6 +14,7 @@ call mtr.add_suppression("InnoDB: Table `test`\\.`t[12]` (has an unreadable root
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[12]\\.ibd' cannot be decrypted\\.");
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=3\\] in file .*test.t1.ibd looks corrupted; key_version=1");
+call mtr.add_suppression("InnoDB: Table `test`\\.`t[12]` is corrupted");
call mtr.add_suppression("File '.*mysql-test.std_data.keysbad3\\.txt' not found");
--echo # Start server with keys2.txt
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 5b449abd6cd..f100c330bad 100644
--- a/mysql-test/suite/encryption/t/innodb-bad-key-change2.test
+++ b/mysql-test/suite/encryption/t/innodb-bad-key-change2.test
@@ -14,6 +14,9 @@ call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]
# Suppression for builds where file_key_management plugin is linked statically
call mtr.add_suppression("Couldn't load plugins from 'file_key_management");
call mtr.add_suppression("InnoDB: Tablespace for table \`test\`.\`t1\` is set as discarded\\.");
+call mtr.add_suppression("InnoDB: Table `test`\\.`t1` is corrupted");
+call mtr.add_suppression("InnoDB: Cannot delete tablespace .* because it is not found in the tablespace memory cache");
+call mtr.add_suppression("InnoDB: ALTER TABLE `test`\\.`t1` DISCARD TABLESPACE failed to find tablespace");
--let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
--source include/restart_mysqld.inc
@@ -76,6 +79,14 @@ EOF
--let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
--source include/restart_mysqld.inc
+ALTER TABLE t1 DISCARD TABLESPACE;
+
+perl;
+do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
+ib_discard_tablespaces("test", "t1");
+ib_restore_tablespaces("test", "t1");
+EOF
+
ALTER TABLE t1 IMPORT TABLESPACE;
SHOW CREATE TABLE t1;
@@ -87,5 +98,4 @@ RENAME TABLE t1 TO t1new;
--error ER_NO_SUCH_TABLE_IN_ENGINE
ALTER TABLE t1 RENAME TO t1new;
# Drop should pass even with incorrect keys
---replace_regex /(tablespace|key_id) [1-9][0-9]*/\1 /
DROP TABLE t1;
diff --git a/mysql-test/suite/encryption/t/innodb-bad-key-change4.test b/mysql-test/suite/encryption/t/innodb-bad-key-change4.test
index 4d5f6e38ba8..d2f75a3d6c1 100644
--- a/mysql-test/suite/encryption/t/innodb-bad-key-change4.test
+++ b/mysql-test/suite/encryption/t/innodb-bad-key-change4.test
@@ -12,6 +12,7 @@ call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page n
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
# Suppression for builds where file_key_management plugin is linked statically
call mtr.add_suppression("Couldn't load plugins from 'file_key_management");
+call mtr.add_suppression("InnoDB: Table `test`\\.`t1` is corrupted");
--let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
--source include/restart_mysqld.inc
diff --git a/mysql-test/suite/encryption/t/innodb-compressed-blob.test b/mysql-test/suite/encryption/t/innodb-compressed-blob.test
index 695864db123..261fdd73aa1 100644
--- a/mysql-test/suite/encryption/t/innodb-compressed-blob.test
+++ b/mysql-test/suite/encryption/t/innodb-compressed-blob.test
@@ -7,6 +7,7 @@
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\.");
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
call mtr.add_suppression("InnoDB: Unable to decompress ..test.t[1-3]\\.ibd\\[page id: space=[1-9][0-9]*, page number=[0-9]+\\]");
+call mtr.add_suppression("InnoDB: Table `test`\\.`t[12]` is corrupted");
--echo # Restart mysqld --file-key-management-filename=keys2.txt
-- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
@@ -27,9 +28,9 @@ insert into t3 values (1, repeat('secret',6000));
-- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt
-- source include/restart_mysqld.inc
---error ER_GET_ERRMSG
+--error ER_NO_SUCH_TABLE_IN_ENGINE
select count(*) from t1 FORCE INDEX (b) where b like 'secret%';
---error ER_GET_ERRMSG
+--error ER_NO_SUCH_TABLE_IN_ENGINE
select count(*) from t2 FORCE INDEX (b) where b like 'secret%';
select count(*) from t3 FORCE INDEX (b) where b like 'secret%';
diff --git a/mysql-test/suite/encryption/t/innodb-encryption-disable.test b/mysql-test/suite/encryption/t/innodb-encryption-disable.test
index 6d6f1c40d4c..4d0aa04bc56 100644
--- a/mysql-test/suite/encryption/t/innodb-encryption-disable.test
+++ b/mysql-test/suite/encryption/t/innodb-encryption-disable.test
@@ -11,6 +11,7 @@ call mtr.add_suppression("InnoDB: Table `test`\\.`t[15]` (has an unreadable root
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[15]\\.ibd' cannot be decrypted\\.");
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=3\\] in file .*test.t[15].ibd looks corrupted; key_version=1");
+call mtr.add_suppression("InnoDB: Table `test`\\.`t[15]` is corrupted");
# Suppression for builds where file_key_management plugin is linked statically
call mtr.add_suppression("Couldn't load plugins from 'file_key_management");
diff --git a/mysql-test/suite/encryption/t/innodb-force-corrupt.test b/mysql-test/suite/encryption/t/innodb-force-corrupt.test
index 9d10a152995..e8048150be2 100644
--- a/mysql-test/suite/encryption/t/innodb-force-corrupt.test
+++ b/mysql-test/suite/encryption/t/innodb-force-corrupt.test
@@ -9,6 +9,7 @@
call mtr.add_suppression("InnoDB: Table `test`\\.`t[13]` (has an unreadable root page|is corrupted)");
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=\\d+, page number=[36]\\] in file .*test.t[123]\\.ibd looks corrupted; key_version=");
+call mtr.add_suppression("InnoDB: Table `test`\\.`t[13]` is corrupted");
SET GLOBAL innodb_file_per_table = ON;
set global innodb_compression_algorithm = 1;
diff --git a/mysql-test/suite/encryption/t/innodb-missing-key.test b/mysql-test/suite/encryption/t/innodb-missing-key.test
index c2a73d594b4..0b81d37ac50 100644
--- a/mysql-test/suite/encryption/t/innodb-missing-key.test
+++ b/mysql-test/suite/encryption/t/innodb-missing-key.test
@@ -11,6 +11,7 @@ call mtr.add_suppression("InnoDB: Table `test`\\.`t1` (has an unreadable root pa
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\.");
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file .*test.t[12].ibd looks corrupted; key_version=1");
+call mtr.add_suppression("InnoDB: Table `test`\\.`t1` is corrupted");
--echo # Start server with keys2.txt
-- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt
diff --git a/mysql-test/suite/innodb/r/alter_kill.result b/mysql-test/suite/innodb/r/alter_kill.result
index e89e1a2c68a..8195d8e8ed1 100644
--- a/mysql-test/suite/innodb/r/alter_kill.result
+++ b/mysql-test/suite/innodb/r/alter_kill.result
@@ -13,43 +13,18 @@ connection default;
disconnect con1;
# Corrupt FIL_PAGE_OFFSET in bug16720368.ibd,
# and recompute innodb_checksum_algorithm=crc32
-# Restart mysqld
# restart
-# This will succeed after a clean shutdown, due to
-# fil_open_single_table_tablespace(check_space_id=FALSE).
-SELECT COUNT(*) FROM bug16720368;
-COUNT(*)
-8
-INSERT INTO bug16720368_1 VALUES(1);
-# restart
-# The table is unaccessible, because after a crash we will
-# validate the tablespace header.
SELECT COUNT(*) FROM bug16720368;
ERROR 42S02: Table 'test.bug16720368' doesn't exist in engine
-INSERT INTO bug16720368 VALUES(0,1);
+INSERT INTO bug16720368 VALUES(1);
ERROR 42S02: Table 'test.bug16720368' doesn't exist in engine
-# restart: --innodb-force-recovery=3
-# The table is readable thanks to innodb-force-recovery.
-SELECT COUNT(*) FROM bug16720368;
-COUNT(*)
-8
-INSERT INTO bug16720368 VALUES(0,1);
-# Shut down the server cleanly to hide the corruption.
-# restart
-# The table is accessible, because after a clean shutdown we will
-# NOT validate the tablespace header.
-# We can modify the existing pages, but we cannot allocate or free
-# any pages, because that would hit the corruption on page 0.
-SELECT COUNT(*) FROM bug16720368;
-COUNT(*)
-9
+INSERT INTO bug16720368_1 VALUES(1);
# Shut down the server to uncorrupt the data.
-# Restart the server after uncorrupting the file.
# restart
INSERT INTO bug16720368 VALUES(9,1);
SELECT COUNT(*) FROM bug16720368;
COUNT(*)
-10
+9
DROP TABLE bug16720368, bug16720368_1;
#
# Bug#16735660 ASSERT TABLE2 == NULL, ROLLBACK OF RESURRECTED TXNS,
diff --git a/mysql-test/suite/innodb/t/alter_kill.test b/mysql-test/suite/innodb/t/alter_kill.test
index 91d62a79342..2313d63db69 100644
--- a/mysql-test/suite/innodb/t/alter_kill.test
+++ b/mysql-test/suite/innodb/t/alter_kill.test
@@ -19,6 +19,7 @@ call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore this and
call mtr.add_suppression("InnoDB: Plugin initialization aborted*");
call mtr.add_suppression("Plugin 'InnoDB' init function returned error.");
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed.");
+call mtr.add_suppression("InnoDB: Table `test`\\.`bug16720368` is corrupted");
-- enable_query_log
-- echo #
@@ -52,9 +53,11 @@ binmode FILE;
my $ps= $ENV{PAGE_SIZE};
my $page;
die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
+my $full_crc32 = unpack("N",substr($page,54,4)) & 0x10; # FIL_SPACE_FLAGS
+sysseek(FILE, 3*$ps, 0) || die "Unable to seek $file\n";
+die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
substr($page,4,4)=pack("N",0xc001cafe);
my $polynomial = 0x82f63b78; # CRC-32C
-my $full_crc32 = unpack("N",substr($page,54,4)) & 0x10; # FIL_SPACE_FLAGS
if ($full_crc32)
{
my $ck = mycrc32(substr($page, 0, $ps-4), 0, $polynomial);
@@ -67,48 +70,18 @@ else
substr($page,0,4)=$ck;
substr($page,$ps-8,4)=$ck;
}
-sysseek(FILE, 0, 0) || die "Unable to rewind $file\n";
+sysseek(FILE, 3*$ps, 0) || die "Unable to rewind $file\n";
syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n";
close(FILE) || die "Unable to close $file";
EOF
--- echo # Restart mysqld
-- source include/start_mysqld.inc
--- echo # This will succeed after a clean shutdown, due to
--- echo # fil_open_single_table_tablespace(check_space_id=FALSE).
-SELECT COUNT(*) FROM bug16720368;
-
-INSERT INTO bug16720368_1 VALUES(1);
-
---let $shutdown_timeout= 0
---source include/restart_mysqld.inc
-
--- echo # The table is unaccessible, because after a crash we will
--- echo # validate the tablespace header.
--error ER_NO_SUCH_TABLE_IN_ENGINE
SELECT COUNT(*) FROM bug16720368;
--error ER_NO_SUCH_TABLE_IN_ENGINE
-INSERT INTO bug16720368 VALUES(0,1);
-
-let $restart_parameters = --innodb-force-recovery=3;
---let $shutdown_timeout= 0
---source include/restart_mysqld.inc
-
--- echo # The table is readable thanks to innodb-force-recovery.
-SELECT COUNT(*) FROM bug16720368;
-INSERT INTO bug16720368 VALUES(0,1);
-
--- echo # Shut down the server cleanly to hide the corruption.
-let $shutdown_timeout=;
-let $restart_parameters =;
--- source include/restart_mysqld.inc
-
--- echo # The table is accessible, because after a clean shutdown we will
--- echo # NOT validate the tablespace header.
--- echo # We can modify the existing pages, but we cannot allocate or free
--- echo # any pages, because that would hit the corruption on page 0.
-SELECT COUNT(*) FROM bug16720368;
+INSERT INTO bug16720368 VALUES(1);
+INSERT INTO bug16720368_1 VALUES(1);
-- echo # Shut down the server to uncorrupt the data.
-- source include/shutdown_mysqld.inc
@@ -122,9 +95,11 @@ binmode FILE;
my $ps= $ENV{PAGE_SIZE};
my $page;
die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
-substr($page,4,4)=pack("N",0);
-my $polynomial = 0x82f63b78; # CRC-32C
my $full_crc32 = unpack("N",substr($page,54,4)) & 0x10; # FIL_SPACE_FLAGS
+sysseek(FILE, 3*$ps, 0) || die "Unable to seek $file\n";
+die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
+substr($page,4,4)=pack("N",3);
+my $polynomial = 0x82f63b78; # CRC-32C
if ($full_crc32)
{
my $ck = mycrc32(substr($page, 0, $ps-4), 0, $polynomial);
@@ -137,12 +112,11 @@ else
substr($page,0,4)=$ck;
substr($page,$ps-8,4)=$ck;
}
-sysseek(FILE, 0, 0) || die "Unable to rewind $file\n";
+sysseek(FILE, 3*$ps, 0) || die "Unable to rewind $file\n";
syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n";
close(FILE) || die "Unable to close $file";
EOF
--- echo # Restart the server after uncorrupting the file.
-- source include/start_mysqld.inc
INSERT INTO bug16720368 VALUES(9,1);
diff --git a/mysql-test/suite/mariabackup/unencrypted_page_compressed.result b/mysql-test/suite/mariabackup/unencrypted_page_compressed.result
index 6ed06eab4aa..7edf66b027a 100644
--- a/mysql-test/suite/mariabackup/unencrypted_page_compressed.result
+++ b/mysql-test/suite/mariabackup/unencrypted_page_compressed.result
@@ -8,5 +8,3 @@ InnoDB 0 transactions not purged
# xtrabackup backup
FOUND 1 /Database page corruption detected.*/ in backup.log
drop table t1;
-Warnings:
-Warning 192 Table test/t1 in file ./test/t1.ibd is encrypted but encryption service or used key_id is not available. Can't continue reading table.
diff --git a/sql/item_func.h b/sql/item_func.h
index aaf5eaacc88..a3bf4d78158 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -2662,7 +2662,6 @@ class Item_func_set_user_var :public Item_func_user_var
user variable it the first connection context).
*/
my_thread_id entry_thread_id;
- char buffer[MAX_FIELD_WIDTH];
String value;
my_decimal decimal_buff;
bool null_item;
diff --git a/storage/federatedx/ha_federatedx.h b/storage/federatedx/ha_federatedx.h
index 10e2a7cfcc4..67aa83f7b33 100644
--- a/storage/federatedx/ha_federatedx.h
+++ b/storage/federatedx/ha_federatedx.h
@@ -274,7 +274,6 @@ class ha_federatedx: public handler
*/
DYNAMIC_ARRAY results;
bool position_called;
- uint fetch_num; // stores the fetch num
int remote_error_number;
char remote_error_buf[FEDERATEDX_QUERY_BUFFER_SIZE];
bool ignore_duplicates, replace_duplicates;
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc
index 6723045b9f6..3c79fe6a72d 100644
--- a/storage/innobase/btr/btr0btr.cc
+++ b/storage/innobase/btr/btr0btr.cc
@@ -236,7 +236,7 @@ btr_root_block_get(
"Table %s in file %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
- index->table->name,
+ index->table->name.m_name,
UT_LIST_GET_FIRST(index->table->space->chain)->name);
return NULL;
@@ -5015,13 +5015,6 @@ btr_validate_level(
block = btr_root_block_get(index, RW_SX_LATCH, &mtr);
page = buf_block_get_frame(block);
-#ifdef UNIV_DEBUG
- if (dict_index_is_spatial(index)) {
- fprintf(stderr, "Root page no: %lu\n",
- (ulong) page_get_page_no(page));
- }
-#endif
-
fil_space_t* space = index->table->space;
const ulint zip_size = space->zip_size();
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index 9fba62e5b15..0b61e340f81 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -1560,7 +1560,7 @@ retry_page_get:
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
- index->table->name);
+ index->table->name.m_name);
index->table->file_unreadable = true;
}
@@ -1673,7 +1673,7 @@ retry_page_get:
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
- index->table->name);
+ index->table->name.m_name);
index->table->file_unreadable = true;
}
@@ -1702,7 +1702,7 @@ retry_page_get:
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
- index->table->name);
+ index->table->name.m_name);
index->table->file_unreadable = true;
}
@@ -2609,7 +2609,7 @@ btr_cur_open_at_index_side_func(
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
- index->table->name);
+ index->table->name.m_name);
index->table->file_unreadable = true;
}
@@ -2968,7 +2968,7 @@ btr_cur_open_at_rnd_pos_func(
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
- index->table->name);
+ index->table->name.m_name);
index->table->file_unreadable = true;
}
@@ -6260,7 +6260,7 @@ btr_estimate_n_rows_in_range_on_level(
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
- index->table->name);
+ index->table->name.m_name);
index->table->file_unreadable = true;
}
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index a25e93d7439..2828e63889a 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -4665,7 +4665,9 @@ evict_from_pool:
buf_pool_mutex_exit(buf_pool);
rw_lock_x_unlock(&fix_block->lock);
- *err = DB_PAGE_CORRUPTED;
+ if (err) {
+ *err = DB_PAGE_CORRUPTED;
+ }
return NULL;
}
}
diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc
index fe1628caac5..c59f6107c5c 100644
--- a/storage/innobase/dict/dict0load.cc
+++ b/storage/innobase/dict/dict0load.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2016, 2018, MariaDB Corporation.
+Copyright (c) 2016, 2019, MariaDB Corporation.
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
@@ -81,7 +81,7 @@ file_unreadable flag in the table object we return */
static
dict_table_t*
dict_load_table_one(
- table_name_t& name,
+ const table_name_t& name,
bool cached,
dict_err_ignore_t ignore_err,
dict_names_t& fk_tables);
@@ -93,9 +93,8 @@ Do not load any columns or indexes.
@param[out,own] table table, or NULL
@return error message
@retval NULL on success */
-static
-const char*
-dict_load_table_low(table_name_t& name, const rec_t* rec, dict_table_t** table)
+static const char* dict_load_table_low(const table_name_t& name,
+ const rec_t* rec, dict_table_t** table)
MY_ATTRIBUTE((nonnull, warn_unused_result));
/** Load an index definition from a SYS_INDEXES record to dict_index_t.
@@ -385,7 +384,6 @@ dict_process_sys_tables_rec_and_mtr_commit(
{
ulint len;
const char* field;
- table_name_t table_name;
field = (const char*) rec_get_nth_field_old(
rec, DICT_FLD__SYS_TABLES__NAME, &len);
@@ -395,7 +393,7 @@ dict_process_sys_tables_rec_and_mtr_commit(
ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_S_FIX));
/* Get the table name */
- table_name.m_name = mem_heap_strdupl(heap, field, len);
+ table_name_t table_name(mem_heap_strdupl(heap, field, len));
if (cached) {
/* Commit before load the table again */
@@ -1341,14 +1339,9 @@ dict_sys_tables_rec_read(
/** Load and check each non-predefined tablespace mentioned in SYS_TABLES.
Search SYS_TABLES and check each tablespace mentioned that has not
already been added to the fil_system. If it is valid, add it to the
-file_system list. Perform extra validation on the table if recovery from
-the REDO log occurred.
-@param[in] validate Whether to do validation on the table.
+file_system list.
@return the highest space ID found. */
-UNIV_INLINE
-ulint
-dict_check_sys_tables(
- bool validate)
+static ulint dict_check_sys_tables()
{
ulint max_space_id = 0;
btr_pcur_t pcur;
@@ -1376,7 +1369,6 @@ dict_check_sys_tables(
rec = dict_getnext_system(&pcur, &mtr)) {
const byte* field;
ulint len;
- table_name_t table_name;
table_id_t table_id;
ulint space_id;
ulint n_cols;
@@ -1392,7 +1384,8 @@ dict_check_sys_tables(
/* Copy the table name from rec */
field = rec_get_nth_field_old(
rec, DICT_FLD__SYS_TABLES__NAME, &len);
- table_name.m_name = mem_strdupl((char*) field, len);
+
+ table_name_t table_name(mem_strdupl((char*) field, len));
DBUG_PRINT("dict_check_sys_tables",
("name: %p, '%s'", table_name.m_name,
table_name.m_name));
@@ -1401,15 +1394,22 @@ dict_check_sys_tables(
&table_id, &space_id,
&n_cols, &flags, &flags2)
|| space_id == TRX_SYS_SPACE) {
+next:
ut_free(table_name.m_name);
continue;
}
+ if (strstr(table_name.m_name, "/" TEMP_FILE_PREFIX "-")) {
+ /* This table will be dropped by
+ row_mysql_drop_garbage_tables().
+ We do not care if the file exists. */
+ goto next;
+ }
+
if (flags2 & DICT_TF2_DISCARDED) {
ib::info() << "Ignoring tablespace for " << table_name
<< " because the DISCARD flag is set .";
- ut_free(table_name.m_name);
- continue;
+ goto next;
}
/* For tables or partitions using .ibd files, the flag
@@ -1448,7 +1448,7 @@ dict_check_sys_tables(
/* Check that the .ibd file exists. */
if (!fil_ibd_open(
- validate,
+ false,
!srv_read_only_mode && srv_log_file_size != 0,
FIL_TYPE_TABLESPACE,
space_id, dict_tf_to_fsp_flags(flags),
@@ -1480,11 +1480,8 @@ space_id information in the data dictionary to what we find in the
tablespace file. In addition, more validation will be done if recovery
was needed and force_recovery is not set.
-We also scan the biggest space id, and store it to fil_system.
-@param[in] validate true if recovery was needed */
-void
-dict_check_tablespaces_and_store_max_id(
- bool validate)
+We also scan the biggest space id, and store it to fil_system. */
+void dict_check_tablespaces_and_store_max_id()
{
mtr_t mtr;
@@ -1505,7 +1502,7 @@ dict_check_tablespaces_and_store_max_id(
/* Open all tablespaces referenced in SYS_TABLES.
This will update SYS_TABLESPACES and SYS_DATAFILES if it
finds any file-per-table tablespaces not already there. */
- max_space_id = dict_check_sys_tables(validate);
+ max_space_id = dict_check_sys_tables();
fil_set_max_space_id_if_bigger(max_space_id);
mutex_exit(&dict_sys->mutex);
@@ -2620,9 +2617,8 @@ Do not load any columns or indexes.
@param[out,own] table table, or NULL
@return error message
@retval NULL on success */
-static
-const char*
-dict_load_table_low(table_name_t& name, const rec_t* rec, dict_table_t** table)
+static const char* dict_load_table_low(const table_name_t& name,
+ const rec_t* rec, dict_table_t** table)
{
table_id_t table_id;
ulint space_id;
@@ -2752,32 +2748,22 @@ dict_load_table(
dict_names_t fk_list;
dict_table_t* result;
dict_names_t::iterator i;
- table_name_t table_name;
DBUG_ENTER("dict_load_table");
DBUG_PRINT("dict_load_table", ("loading table: '%s'", name));
ut_ad(mutex_own(&dict_sys->mutex));
- table_name.m_name = const_cast<char*>(name);
-
result = dict_table_check_if_in_cache_low(name);
if (!result) {
- result = dict_load_table_one(table_name, cached, ignore_err,
- fk_list);
+ result = dict_load_table_one(const_cast<char*>(name),
+ cached, ignore_err, fk_list);
while (!fk_list.empty()) {
- table_name_t fk_table_name;
- dict_table_t* fk_table;
-
- fk_table_name.m_name =
- const_cast<char*>(fk_list.front());
- fk_table = dict_table_check_if_in_cache_low(
- fk_table_name.m_name);
- if (!fk_table) {
- dict_load_table_one(fk_table_name, cached,
- ignore_err, fk_list);
- }
+ if (!dict_table_check_if_in_cache_low(fk_list.front()))
+ dict_load_table_one(
+ const_cast<char*>(fk_list.front()),
+ cached, ignore_err, fk_list);
fk_list.pop_front();
}
}
@@ -2877,7 +2863,7 @@ file_unreadable flag in the table object we return */
static
dict_table_t*
dict_load_table_one(
- table_name_t& name,
+ const table_name_t& name,
bool cached,
dict_err_ignore_t ignore_err,
dict_names_t& fk_tables)
@@ -3010,10 +2996,37 @@ err_exit:
if (err == DB_SUCCESS && cached && table->is_readable()) {
if (table->space && !fil_space_get_size(table->space_id)) {
+corrupted:
table->corrupted = true;
table->file_unreadable = true;
- } else if (table->supports_instant()) {
- err = btr_cur_instant_init(table);
+ err = DB_CORRUPTION;
+ } else {
+ const page_id_t page_id(
+ table->space->id,
+ dict_table_get_first_index(table)->page);
+ mtr.start();
+ buf_block_t* block = buf_page_get(
+ page_id, table->space->zip_size(),
+ RW_S_LATCH, &mtr);
+ const bool corrupted = !block
+ || page_get_space_id(block->frame)
+ != page_id.space()
+ || page_get_page_no(block->frame)
+ != page_id.page_no()
+ || (mach_read_from_2(FIL_PAGE_TYPE
+ + block->frame)
+ != FIL_PAGE_INDEX
+ && mach_read_from_2(FIL_PAGE_TYPE
+ + block->frame)
+ != FIL_PAGE_TYPE_INSTANT);
+ mtr.commit();
+ if (corrupted) {
+ goto corrupted;
+ }
+
+ if (table->supports_instant()) {
+ err = btr_cur_instant_init(table);
+ }
}
}
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 9e6d1a35536..828773fe761 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -13008,10 +13008,8 @@ inline int ha_innobase::delete_table(const char* name, enum_sql_command sqlcom)
err = row_drop_database_for_mysql(norm_name, trx,
&num_partitions);
norm_name[len] = 0;
- if (num_partitions == 0
- && !row_is_mysql_tmp_table_name(norm_name)) {
- table_name_t tbl_name;
- tbl_name.m_name = norm_name;
+ table_name_t tbl_name(norm_name);
+ if (num_partitions == 0 && !tbl_name.is_temporary()) {
ib::error() << "Table " << tbl_name <<
" does not exist in the InnoDB"
" internal data dictionary though MariaDB is"
@@ -14444,7 +14442,7 @@ ha_innobase::optimize(
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
uint(err),
"InnoDB: Cannot defragment table %s: returned error code %d\n",
- m_prebuilt->table->name, err);
+ m_prebuilt->table->name.m_name, err);
if(err == ER_SP_ALREADY_EXISTS) {
try_alter = false;
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 6b99d91532e..ad8d065de90 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -9426,13 +9426,11 @@ innobase_update_foreign_cache(
fk_tables.front(), true, DICT_ERR_IGNORE_NONE);
if (table == NULL) {
- table_name_t table_name;
- table_name.m_name = const_cast<char*>(
- fk_tables.front());
-
err = DB_TABLE_NOT_FOUND;
ib::error()
- << "Failed to load table '" << table_name
+ << "Failed to load table '"
+ << table_name_t(const_cast<char*>
+ (fk_tables.front()))
<< "' which has a foreign key constraint with"
<< " table '" << user_table->name << "'.";
break;
diff --git a/storage/innobase/include/dict0crea.ic b/storage/innobase/include/dict0crea.ic
index 00e4e54115a..a9c4fa7b010 100644
--- a/storage/innobase/include/dict0crea.ic
+++ b/storage/innobase/include/dict0crea.ic
@@ -28,18 +28,6 @@ Created 1/8/1996 Heikki Tuuri
#include "mem0mem.h"
-/*********************************************************************//**
-Checks if a table name contains the string "/#sql" which denotes temporary
-tables in MySQL.
-@return true if temporary table */
-bool
-row_is_mysql_tmp_table_name(
-/*========================*/
- const char* name) MY_ATTRIBUTE((warn_unused_result));
- /*!< in: table name in the form
- 'database/tablename' */
-
-
/********************************************************************//**
Generate a foreign key constraint name when it was not named by the user.
A generated constraint has a name of the format dbname/tablename_ibfk_NUMBER,
@@ -63,7 +51,7 @@ dict_create_add_foreign_id(
mem_heap_alloc(foreign->heap,
namelen + 20));
- if (row_is_mysql_tmp_table_name(name)) {
+ if (dict_table_t::is_temporary_name(name)) {
/* no overflow if number < 1e13 */
sprintf(id, "%s_ibfk_%lu", name,
diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h
index cddfbc68cb7..670f4646f9d 100644
--- a/storage/innobase/include/dict0load.h
+++ b/storage/innobase/include/dict0load.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2018, MariaDB Corporation.
+Copyright (c) 2017, 2019, MariaDB Corporation.
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
@@ -67,11 +67,8 @@ space_id information in the data dictionary to what we find in the
tablespace file. In addition, more validation will be done if recovery
was needed and force_recovery is not set.
-We also scan the biggest space id, and store it to fil_system.
-@param[in] validate true if recovery was needed */
-void
-dict_check_tablespaces_and_store_max_id(
- bool validate);
+We also scan the biggest space id, and store it to fil_system. */
+void dict_check_tablespaces_and_store_max_id();
/********************************************************************//**
Finds the first table name in the given database.
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index 858cc82b1fd..2e8b8d72c93 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -1649,6 +1649,13 @@ struct dict_table_t {
return(UNIV_LIKELY(!file_unreadable));
}
+ /** Check if a table name contains the string "/#sql"
+ which denotes temporary or intermediate tables in MariaDB. */
+ static bool is_temporary_name(const char* name)
+ {
+ return strstr(name, "/" TEMP_FILE_PREFIX) != NULL;
+ }
+
/** @return whether instant ALTER TABLE is in effect */
bool is_instant() const
{
@@ -2152,6 +2159,11 @@ inline void dict_index_t::set_modified(mtr_t& mtr) const
mtr.set_named_space(table->space);
}
+inline bool table_name_t::is_temporary() const
+{
+ return dict_table_t::is_temporary_name(m_name);
+}
+
inline bool dict_index_t::is_readable() const { return table->is_readable(); }
inline bool dict_index_t::is_instant() const
diff --git a/storage/innobase/include/dict0types.h b/storage/innobase/include/dict0types.h
index f2fcae69bd5..e3b536b83ee 100644
--- a/storage/innobase/include/dict0types.h
+++ b/storage/innobase/include/dict0types.h
@@ -106,6 +106,11 @@ struct table_name_t
/** The name in internal representation */
char* m_name;
+ /** Default constructor */
+ table_name_t() {}
+ /** Constructor */
+ table_name_t(char* name) : m_name(name) {}
+
/** @return the end of the schema name */
const char* dbend() const
{
@@ -128,6 +133,9 @@ struct table_name_t
@return the partition name
@retval NULL if the table is not partitioned */
const char* part() const { return strstr(basename(), part_suffix); }
+
+ /** @return whether this is a temporary or intermediate table name */
+ inline bool is_temporary() const;
};
#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h
index 94b1ebaa4c5..9d8b425fbba 100644
--- a/storage/innobase/include/row0mysql.h
+++ b/storage/innobase/include/row0mysql.h
@@ -290,17 +290,6 @@ row_unlock_for_mysql(
ibool has_latches_on_recs);
/*********************************************************************//**
-Checks if a table name contains the string "/#sql" which denotes temporary
-tables in MySQL.
-@return true if temporary table */
-bool
-row_is_mysql_tmp_table_name(
-/*========================*/
- const char* name) MY_ATTRIBUTE((warn_unused_result));
- /*!< in: table name in the form
- 'database/tablename' */
-
-/*********************************************************************//**
Creates an query graph node of 'update' type to be used in the MySQL
interface.
@return own: update node */
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index 98350fca7c7..cc30de70798 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -2992,7 +2992,7 @@ row_ins_sec_index_entry_low(
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
- index->table->name);
+ index->table->name.m_name);
index->table->file_unreadable = true;
}
goto func_exit;
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index 87fdf6b0643..8f0b7727b49 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -1313,7 +1313,7 @@ row_mysql_get_table_status(
"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.",
- table->name, table->space);
+ table->name.m_name, table->space);
}
err = DB_DECRYPTION_FAILED;
@@ -1321,7 +1321,7 @@ row_mysql_get_table_status(
if (push_warning) {
ib_push_warning(trx, DB_CORRUPTION,
"Table %s in tablespace %lu corrupted.",
- table->name, table->space);
+ table->name.m_name, table->space);
}
err = DB_CORRUPTION;
@@ -3996,7 +3996,7 @@ loop:
}
- if (!row_is_mysql_tmp_table_name(table->name.m_name)) {
+ if (!table->name.is_temporary()) {
/* There could be orphan temp tables left from
interrupted alter table. Leave them, and handle
the rest.*/
@@ -4089,21 +4089,6 @@ loop:
DBUG_RETURN(err);
}
-/*********************************************************************//**
-Checks if a table name contains the string "/#sql" which denotes temporary
-tables in MySQL.
-@return true if temporary table */
-MY_ATTRIBUTE((warn_unused_result))
-bool
-row_is_mysql_tmp_table_name(
-/*========================*/
- const char* name) /*!< in: table name in the form
- 'database/tablename' */
-{
- return(strstr(name, "/" TEMP_FILE_PREFIX) != NULL);
- /* return(strstr(name, "/@0023sql") != NULL); */
-}
-
/****************************************************************//**
Delete a single constraint.
@return error code or DB_SUCCESS */
@@ -4203,8 +4188,8 @@ row_rename_table_for_mysql(
trx->op_info = "renaming table";
- old_is_tmp = row_is_mysql_tmp_table_name(old_name);
- new_is_tmp = row_is_mysql_tmp_table_name(new_name);
+ old_is_tmp = dict_table_t::is_temporary_name(old_name);
+ new_is_tmp = dict_table_t::is_temporary_name(new_name);
dict_locked = trx->dict_operation_lock_mode == RW_X_LATCH;
diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc
index 3d59e08b988..9a3f3bb9be7 100644
--- a/storage/innobase/row/row0sel.cc
+++ b/storage/innobase/row/row0sel.cc
@@ -4630,7 +4630,7 @@ wait_table_again:
"Table %s is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
- prebuilt->table->name);
+ prebuilt->table->name.m_name);
index->table->file_unreadable = true;
}
rec = NULL;
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index e82d486c206..d67c6c02b2f 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -2136,19 +2136,8 @@ files_checked:
every table in the InnoDB data dictionary that has
an .ibd file.
- We also determine the maximum tablespace id used.
-
- The 'validate' flag indicates that when a tablespace
- is opened, we also read the header page and validate
- the contents to the data dictionary. This is time
- consuming, especially for databases with lots of ibd
- files. So only do it after a crash and not forcing
- recovery. Open rw transactions at this point is not
- a good reason to validate. */
- bool validate = recv_needed_recovery
- && srv_force_recovery == 0;
-
- dict_check_tablespaces_and_store_max_id(validate);
+ We also determine the maximum tablespace id used. */
+ dict_check_tablespaces_and_store_max_id();
}
if (err != DB_SUCCESS) {