summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-04-04 19:41:12 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-04-04 19:41:12 +0300
commitd5a2bc6a0f24f2a9ec73a0d18bb7e6fba3496bed (patch)
treea938d6ee4bc415f07469194860af8f35bba83be4
parent532fffb4cc7fd68b702aed94e01718c9532c119f (diff)
parentb30fb701cc040cd9243a3634240672b27f78d142 (diff)
downloadmariadb-git-d5a2bc6a0f24f2a9ec73a0d18bb7e6fba3496bed.tar.gz
Merge 10.2 into 10.3
-rw-r--r--mysql-test/include/check-testcase.test2
-rw-r--r--mysql-test/include/index_merge1.inc4
-rw-r--r--mysql-test/include/index_merge2.inc8
-rw-r--r--mysql-test/include/index_merge_2sweeps.inc2
-rw-r--r--mysql-test/include/index_merge_ror.inc8
-rw-r--r--mysql-test/include/index_merge_ror_cpk.inc4
-rw-r--r--mysql-test/main/index_merge_innodb.result5
-rw-r--r--mysql-test/main/index_merge_innodb.test2
-rw-r--r--mysql-test/main/index_merge_myisam.result3
-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.result26
-rw-r--r--mysql-test/suite/innodb/t/alter_kill.test43
-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.cc108
-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.h13
-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
43 files changed, 192 insertions, 212 deletions
diff --git a/mysql-test/include/check-testcase.test b/mysql-test/include/check-testcase.test
index 3c164eef8b6..44aa4472cba 100644
--- a/mysql-test/include/check-testcase.test
+++ b/mysql-test/include/check-testcase.test
@@ -86,7 +86,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/include/index_merge1.inc b/mysql-test/include/index_merge1.inc
index b63b2db78da..0fb94b96ab4 100644
--- a/mysql-test/include/index_merge1.inc
+++ b/mysql-test/include/index_merge1.inc
@@ -37,12 +37,14 @@ insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8);
let $1=7;
set @d=8;
+begin;
while ($1)
{
eval insert into t0 select key1+@d from t0;
eval set @d=@d*2;
dec $1;
}
+commit;
--enable_query_log
alter table t0 add key2 int not null, add index i2(key2);
@@ -362,6 +364,7 @@ INSERT INTO t1 VALUES ('foo','bar', 'ZZ'),('fuz','baz', 'ZZ');
--disable_query_log
let $1=9;
+begin;
while ($1)
{
eval INSERT INTO t1 SELECT * from t1 WHERE cola = 'foo';
@@ -374,6 +377,7 @@ while ($1)
eval INSERT INTO t1 SELECT * from t1 WHERE cola <> 'foo';
dec $1;
}
+commit;
--enable_query_log
diff --git a/mysql-test/include/index_merge2.inc b/mysql-test/include/index_merge2.inc
index 03afa49d323..ae9adac882f 100644
--- a/mysql-test/include/index_merge2.inc
+++ b/mysql-test/include/index_merge2.inc
@@ -34,11 +34,13 @@ create table t1
--disable_query_log
let $1=200;
+begin;
while ($1)
{
eval insert into t1 values (200-$1, $1);
dec $1;
}
+commit;
--enable_query_log
# No primary key
@@ -80,11 +82,13 @@ create table t1 (
show warnings;
--disable_query_log
let $1=30;
+begin;
while ($1)
{
eval insert into t1 (key1, key2, filler) values ($1/4, $1/8, 'filler-data');
dec $1;
}
+commit;
--enable_query_log
explain select pk from t1 where key1 = 1 and key2 = 1;
select pk from t1 where key2 = 1 and key1 = 1;
@@ -331,16 +335,20 @@ insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8);
let $1=7;
set @d=8;
+begin;
while ($1)
{
eval insert into t1 (key1) select key1+@d from t1;
eval set @d=@d*2;
dec $1;
}
+commit;
alter table t1 add index i2(key2);
alter table t1 add index i3(key3);
update t1 set key2=key1,key3=key1;
+
+insert into t1 select 10000+key1, 10000+key2,10000+key3 from t1;
analyze table t1;
# to test the bug, the following must use "sort_union":
diff --git a/mysql-test/include/index_merge_2sweeps.inc b/mysql-test/include/index_merge_2sweeps.inc
index 3ae7e5b3c09..ef356e12969 100644
--- a/mysql-test/include/index_merge_2sweeps.inc
+++ b/mysql-test/include/index_merge_2sweeps.inc
@@ -32,12 +32,14 @@ create table t1 (
--disable_query_log
+begin;
let $1=1000;
while ($1)
{
eval insert into t1 values($1, $1, $1, 'filler-data','filler-data-2');
dec $1;
}
+commit;
--enable_query_log
select * from t1 where (key1 >= 2 and key1 <= 10) or (pk >= 4 and pk <=8 );
diff --git a/mysql-test/include/index_merge_ror.inc b/mysql-test/include/index_merge_ror.inc
index fdb966e6885..3ec6e342994 100644
--- a/mysql-test/include/index_merge_ror.inc
+++ b/mysql-test/include/index_merge_ror.inc
@@ -67,18 +67,21 @@ create table t1
create table t0 as select * from t1;
--disable_query_log
--echo # Printing of many insert into t0 values (....) disabled.
+begin;
let $cnt=1000;
while ($cnt)
{
eval insert into t0 values (1, 2, 3, 1, 2, 3, 0, 0, 0, 0, 'data1', 'data2', 'data3', 'data4', 'data5', 'data6');
dec $cnt;
}
+commit;
--enable_query_log
alter table t1 disable keys;
--disable_query_log
--echo # Printing of many insert into t1 select .... from t0 disabled.
let $1=4;
+begin;
while ($1)
{
let $2=4;
@@ -94,6 +97,7 @@ while ($1)
}
dec $1;
}
+commit;
--echo # Printing of many insert into t1 (...) values (....) disabled.
# Row retrieval tests
@@ -101,6 +105,7 @@ while ($1)
# insert enough rows for index intersection to be used for (key1,key2)
insert into t1 (key1, key2, key3, key4, filler1) values (100, 100, 100, 100,'key1-key2-key3-key4');
let $cnt=400;
+begin;
while ($cnt)
{
eval insert into t1 (key1, key2, key3, key4, filler1) values (100, -1, 100, -1,'key1-key3');
@@ -112,6 +117,7 @@ while ($cnt)
eval insert into t1 (key1, key2, key3, key4, filler1) values (-1, 100, -1, 100,'key2-key4');
dec $cnt;
}
+commit;
--enable_query_log
alter table t1 enable keys;
select count(*) from t1;
@@ -249,6 +255,7 @@ create table t2 (
--disable_query_log
let $1=8;
+begin;
while ($1)
{
eval insert into t2 values (repeat(char($1+64), 8),repeat(char($1+64), 8),'filler1', 'filler2');
@@ -256,6 +263,7 @@ while ($1)
}
insert into t2 select * from t2;
insert into t2 select * from t2;
+commit;
--enable_query_log
# The table row buffer is reused. Fill it with rows that don't match.
diff --git a/mysql-test/include/index_merge_ror_cpk.inc b/mysql-test/include/index_merge_ror_cpk.inc
index df42745b4fc..0a307aa4fdb 100644
--- a/mysql-test/include/index_merge_ror_cpk.inc
+++ b/mysql-test/include/index_merge_ror_cpk.inc
@@ -56,14 +56,14 @@ create table t1
);
--disable_query_log
-set autocommit=0;
+begin;
let $1=10000;
while ($1)
{
eval insert into t1 values ($1 div 10,$1 mod 100, $1/100,$1/100, $1/100,$1/100,$1/100,$1/100,$1/100, $1 mod 100, $1/1000,'filler-data-$1','filler2');
dec $1;
}
-set autocommit=1;
+commit;
--enable_query_log
# Verify that range scan on CPK is ROR
diff --git a/mysql-test/main/index_merge_innodb.result b/mysql-test/main/index_merge_innodb.result
index 6a3ea839535..f27bb263c6f 100644
--- a/mysql-test/main/index_merge_innodb.result
+++ b/mysql-test/main/index_merge_innodb.result
@@ -294,6 +294,7 @@ key3 int not null default 0
);
insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8);
set @d=8;
+begin;
insert into t1 (key1) select key1+@d from t1;
set @d=@d*2;
insert into t1 (key1) select key1+@d from t1;
@@ -308,9 +309,11 @@ insert into t1 (key1) select key1+@d from t1;
set @d=@d*2;
insert into t1 (key1) select key1+@d from t1;
set @d=@d*2;
+commit;
alter table t1 add index i2(key2);
alter table t1 add index i3(key3);
update t1 set key2=key1,key3=key1;
+insert into t1 select 10000+key1, 10000+key2,10000+key3 from t1;
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
@@ -672,6 +675,7 @@ a int,
b int,
INDEX idx(a))
ENGINE=INNODB;
+begin;
INSERT INTO t1(a,b) VALUES
(11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500),
(3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800),
@@ -691,6 +695,7 @@ INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1 VALUES (1000000, 0, 0);
+commit;
SET SESSION sort_buffer_size = 1024*36;
set @tmp_optimizer_switch=@@optimizer_switch;
set optimizer_switch='derived_merge=off,derived_with_keys=off';
diff --git a/mysql-test/main/index_merge_innodb.test b/mysql-test/main/index_merge_innodb.test
index 53ce3114b49..f959db3039a 100644
--- a/mysql-test/main/index_merge_innodb.test
+++ b/mysql-test/main/index_merge_innodb.test
@@ -46,6 +46,7 @@ CREATE TABLE t1 (
INDEX idx(a))
ENGINE=INNODB;
+begin;
INSERT INTO t1(a,b) VALUES
(11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500),
(3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800),
@@ -65,6 +66,7 @@ INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1 VALUES (1000000, 0, 0);
+commit;
SET SESSION sort_buffer_size = 1024*36;
set @tmp_optimizer_switch=@@optimizer_switch;
diff --git a/mysql-test/main/index_merge_myisam.result b/mysql-test/main/index_merge_myisam.result
index 725a888c914..37f5e15a5f7 100644
--- a/mysql-test/main/index_merge_myisam.result
+++ b/mysql-test/main/index_merge_myisam.result
@@ -1132,6 +1132,7 @@ key3 int not null default 0
);
insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8);
set @d=8;
+begin;
insert into t1 (key1) select key1+@d from t1;
set @d=@d*2;
insert into t1 (key1) select key1+@d from t1;
@@ -1146,9 +1147,11 @@ insert into t1 (key1) select key1+@d from t1;
set @d=@d*2;
insert into t1 (key1) select key1+@d from t1;
set @d=@d*2;
+commit;
alter table t1 add index i2(key2);
alter table t1 add index i3(key3);
update t1 set key2=key1,key3=key1;
+insert into t1 select 10000+key1, 10000+key2,10000+key3 from t1;
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
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 5812ff6dce9..68267f2498d 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
SET GLOBAL innodb_file_per_table = ON;
@@ -30,8 +31,6 @@ foobar 2
SELECT * FROM t1;
ERROR 42S02: Table 'test.t1' doesn't exist in engine
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
SET GLOBAL innodb_default_encryption_key_id=5;
CREATE TABLE t2 (c VARCHAR(8), id int not null primary key, b int, key(b)) ENGINE=InnoDB ENCRYPTED=YES;
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 bd464cbe43a..9cf98b6b1fd 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");
SET GLOBAL innodb_file_per_table = ON;
CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB
ENCRYPTED=YES ENCRYPTION_KEY_ID=4;
@@ -11,7 +14,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
@@ -40,9 +42,12 @@ CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB
ENCRYPTED=YES ENCRYPTION_KEY_ID=4;
ALTER TABLE t1 DISCARD TABLESPACE;
restore: t1 .ibd and .cfg files
-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 0d424677981..d3bbe2eccf3 100644
--- a/mysql-test/suite/encryption/r/innodb-bad-key-change4.result
+++ b/mysql-test/suite/encryption/r/innodb-bad-key-change4.result
@@ -2,13 +2,13 @@ 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");
SET GLOBAL innodb_file_per_table = ON;
CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB
ENCRYPTED=YES ENCRYPTION_KEY_ID=4;
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
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 f163f6141dd..ef49c9a6541 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
SET GLOBAL innodb_file_per_table = ON;
set GLOBAL innodb_default_encryption_key_id=4;
@@ -14,9 +15,9 @@ insert into t2 values (1, repeat('secret',6000));
insert into t3 values (1, repeat('secret',6000));
# Restart mysqld --file-key-management-filename=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 94b47103dd0..9d6da0a0291 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");
create table t5 (
`intcol1` int(32) DEFAULT NULL,
diff --git a/mysql-test/suite/encryption/r/innodb-force-corrupt.result b/mysql-test/suite/encryption/r/innodb-force-corrupt.result
index 13c38f1587d..c1145e574b7 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=3221342974");
+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 6f4a45d817a..3a501335e2d 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
CREATE TABLE t1(a int not null primary key auto_increment, b varchar(128)) engine=innodb ENCRYPTED=YES ENCRYPTION_KEY_ID=19;
CREATE TABLE t2(a int not null primary key auto_increment, b varchar(128)) engine=innodb ENCRYPTED=YES ENCRYPTION_KEY_ID=1;
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 6c775dbf733..ae7e5c81aa1 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=3221342974");
+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 4188031eed9..0f2e7b34837 100644
--- a/mysql-test/suite/innodb/r/alter_kill.result
+++ b/mysql-test/suite/innodb/r/alter_kill.result
@@ -14,37 +14,17 @@ disconnect con1;
# Corrupt FIL_PAGE_OFFSET in bug16720368.ibd,
# and recompute innodb_checksum_algorithm=crc32
# Restart mysqld
-# 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);
-# 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
-# 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.
-# 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.
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 17b88a00155..daaac4bc0ee 100644
--- a/mysql-test/suite/innodb/t/alter_kill.test
+++ b/mysql-test/suite/innodb/t/alter_kill.test
@@ -18,6 +18,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 #
@@ -50,6 +51,7 @@ open(FILE, "+<$file") || die "Unable to open $file";
binmode FILE;
my $ps= $ENV{PAGE_SIZE};
my $page;
+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
@@ -57,7 +59,7 @@ my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^
mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial));
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
@@ -65,40 +67,11 @@ 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
@@ -111,19 +84,21 @@ open(FILE, "+<$file") || die "Unable to open $file";
binmode FILE;
my $ps= $ENV{PAGE_SIZE};
my $page;
+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",0);
+substr($page,4,4)=pack("N",3);
my $polynomial = 0x82f63b78; # CRC-32C
my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^
mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial));
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 71eac085769..daeb9ecf8b7 100644
--- a/mysql-test/suite/mariabackup/unencrypted_page_compressed.result
+++ b/mysql-test/suite/mariabackup/unencrypted_page_compressed.result
@@ -7,5 +7,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 7041272bd1d..80d90ae21c5 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -2404,7 +2404,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 16a1944b172..ffd9274d7eb 100644
--- a/storage/federatedx/ha_federatedx.h
+++ b/storage/federatedx/ha_federatedx.h
@@ -272,7 +272,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 6a269ac3d83..cf027053cf1 100644
--- a/storage/innobase/btr/btr0btr.cc
+++ b/storage/innobase/btr/btr0btr.cc
@@ -237,7 +237,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;
@@ -4917,13 +4917,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 page_size_t table_page_size(
dict_table_page_size(index->table));
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index b80762f178b..1b18aed1f45 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -1470,7 +1470,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;
}
@@ -1583,7 +1583,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;
}
@@ -1612,7 +1612,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;
}
@@ -2518,7 +2518,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;
}
@@ -2877,7 +2877,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;
}
@@ -6024,7 +6024,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 55c8a078d80..e54dd7023e6 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -4675,7 +4675,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 1540f7e53bc..283ad22ba55 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 */
@@ -1339,14 +1337,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;
@@ -1374,7 +1367,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;
@@ -1390,7 +1382,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));
@@ -1399,15 +1392,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
@@ -1446,7 +1446,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),
@@ -1478,11 +1478,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;
@@ -1503,7 +1500,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);
@@ -2618,9 +2615,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;
@@ -2750,32 +2746,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();
}
}
@@ -2875,7 +2861,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)
@@ -3008,10 +2994,38 @@ 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,
+ dict_table_page_size(table),
+ 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 ada9f2b6f5e..9562d1d7462 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -12970,10 +12970,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"
@@ -14407,7 +14405,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 fc714d59568..2d8761e66ac 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -8208,13 +8208,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 ea8460c1376..2cf16dfe57a 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -1504,6 +1504,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 ADD COLUMN is in effect */
bool is_instant() const
{
@@ -1939,6 +1946,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 56c254e1d45..70ec64ea6b4 100644
--- a/storage/innobase/include/row0mysql.h
+++ b/storage/innobase/include/row0mysql.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2000, 2017, 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
@@ -289,17 +289,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 de3745d984e..328943f8715 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -3011,7 +3011,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 5b7fae06c9d..0400cce24ef 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -1312,7 +1312,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;
@@ -1320,7 +1320,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;
@@ -3986,7 +3986,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.*/
@@ -4079,21 +4079,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 */
@@ -4193,8 +4178,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 6faa458033b..d0067f11638 100644
--- a/storage/innobase/row/row0sel.cc
+++ b/storage/innobase/row/row0sel.cc
@@ -4655,7 +4655,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 d733cabf2b0..8164d1df133 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -2256,19 +2256,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();
}
/* Fix-up truncate of table if server crashed while truncate