Commit a6dbb6b2 authored by Marko Mäkelä's avatar Marko Mäkelä

Fix main.create_or_replace better

InnoDB background statistics recalculation may acquire
a metadata also on the table itself, not only on the tables
that store the statistics.

Hence, it is better to disable InnoDB persistent statistics altogether.
This fixes up commit 9b8d9a1d.
parent f92388fa
SET @save_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=OFF;
CREATE TABLE t2 (a int); CREATE TABLE t2 (a int);
INSERT INTO t2 VALUES(1),(2),(3); INSERT INTO t2 VALUES(1),(2),(3);
# #
...@@ -258,8 +260,7 @@ Note 1051 Unknown table 'test.t1,mysqltest2.t2' ...@@ -258,8 +260,7 @@ Note 1051 Unknown table 'test.t1,mysqltest2.t2'
create table test.t1 (i int) engine=myisam; create table test.t1 (i int) engine=myisam;
create table mysqltest2.t2 like test.t1; create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write; lock table test.t1 write, mysqltest2.t2 write;
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock # MDL_BACKUP_DML NULL Backup lock
...@@ -272,8 +273,7 @@ ERROR 42000: A table must have at least 1 column ...@@ -272,8 +273,7 @@ ERROR 42000: A table must have at least 1 column
show tables; show tables;
Tables_in_test Tables_in_test
t2 t2
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock # MDL_BACKUP_DML NULL Backup lock
...@@ -282,16 +282,14 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME ...@@ -282,16 +282,14 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2 # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2
create or replace table mysqltest2.t2; create or replace table mysqltest2.t2;
ERROR 42000: A table must have at least 1 column ERROR 42000: A table must have at least 1 column
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
create table t1 (i int); create table t1 (i int);
drop table t1; drop table t1;
create table test.t1 (i int); create table test.t1 (i int);
create table mysqltest2.t2 like test.t1; create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write; lock table test.t1 write, mysqltest2.t2 write;
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock # MDL_BACKUP_DML NULL Backup lock
...@@ -304,8 +302,7 @@ ERROR 42S21: Duplicate column name 'a' ...@@ -304,8 +302,7 @@ ERROR 42S21: Duplicate column name 'a'
show tables; show tables;
Tables_in_test Tables_in_test
t2 t2
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock # MDL_BACKUP_DML NULL Backup lock
...@@ -314,16 +311,14 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME ...@@ -314,16 +311,14 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2 # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2
create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a'; create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a';
ERROR 42S21: Duplicate column name 'a' ERROR 42S21: Duplicate column name 'a'
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
create table t1 (i int); create table t1 (i int);
drop table t1; drop table t1;
create table test.t1 (i int) engine=innodb; create table test.t1 (i int) engine=innodb;
create table mysqltest2.t2 like test.t1; create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write; lock table test.t1 write, mysqltest2.t2 write;
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DDL NULL Backup lock
# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 # MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2
...@@ -335,8 +330,7 @@ drop table test.t1,mysqltest2.t2; ...@@ -335,8 +330,7 @@ drop table test.t1,mysqltest2.t2;
create table test.t1 (i int) engine=aria transactional=1 checksum=1; create table test.t1 (i int) engine=aria transactional=1 checksum=1;
create table mysqltest2.t2 like test.t1; create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write; lock table test.t1 write, mysqltest2.t2 write;
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DDL NULL Backup lock
# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2 # MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2
...@@ -353,8 +347,7 @@ drop table test.t1; ...@@ -353,8 +347,7 @@ drop table test.t1;
# #
create table t1 (i int); create table t1 (i int);
lock table t1 write; lock table t1 write;
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock # MDL_BACKUP_DML NULL Backup lock
...@@ -365,8 +358,7 @@ ERROR 22001: Data too long for column 'a' at row 1 ...@@ -365,8 +358,7 @@ ERROR 22001: Data too long for column 'a' at row 1
show tables; show tables;
Tables_in_test Tables_in_test
t2 t2
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
create table t1 (i int); create table t1 (i int);
drop table t1; drop table t1;
...@@ -454,8 +446,7 @@ drop view t1; ...@@ -454,8 +446,7 @@ drop view t1;
# #
create table t1 (a int); create table t1 (a int);
lock table t1 write, t2 read; lock table t1 write, t2 read;
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock # MDL_BACKUP_DML NULL Backup lock
...@@ -463,8 +454,7 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME ...@@ -463,8 +454,7 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1
# MDL_SHARED_READ NULL Table metadata lock test t2 # MDL_SHARED_READ NULL Table metadata lock test t2
create or replace table t1 (i int); create or replace table t1 (i int);
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock # MDL_BACKUP_DML NULL Backup lock
...@@ -472,8 +462,7 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME ...@@ -472,8 +462,7 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1
# MDL_SHARED_READ NULL Table metadata lock test t2 # MDL_SHARED_READ NULL Table metadata lock test t2
create or replace table t1 like t2; create or replace table t1 like t2;
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock # MDL_BACKUP_DML NULL Backup lock
...@@ -481,8 +470,7 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME ...@@ -481,8 +470,7 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1 # MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1
# MDL_SHARED_READ NULL Table metadata lock test t2 # MDL_SHARED_READ NULL Table metadata lock test t2
create or replace table t1 select 1 as f1; create or replace table t1 select 1 as f1;
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock # MDL_BACKUP_DML NULL Backup lock
...@@ -580,3 +568,4 @@ ERROR HY000: Table 't3' was not locked with LOCK TABLES ...@@ -580,3 +568,4 @@ ERROR HY000: Table 't3' was not locked with LOCK TABLES
UNLOCK TABLES; UNLOCK TABLES;
DROP TABLE t3; DROP TABLE t3;
# End of 10.4 tests # End of 10.4 tests
SET GLOBAL innodb_stats_persistent=@save_persistent;
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/have_metadata_lock_info.inc --source include/have_metadata_lock_info.inc
SET @save_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=OFF;
# #
# Create help table # Create help table
# #
...@@ -212,21 +215,18 @@ create table mysqltest2.t2 like test.t1; ...@@ -212,21 +215,18 @@ create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write; lock table test.t1 write, mysqltest2.t2 write;
--replace_column 1 # --replace_column 1 #
--sorted_result --sorted_result
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
--error ER_TABLE_MUST_HAVE_COLUMNS --error ER_TABLE_MUST_HAVE_COLUMNS
create or replace table test.t1; create or replace table test.t1;
show tables; show tables;
--replace_column 1 # --replace_column 1 #
--sorted_result --sorted_result
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
--error ER_TABLE_MUST_HAVE_COLUMNS --error ER_TABLE_MUST_HAVE_COLUMNS
create or replace table mysqltest2.t2; create or replace table mysqltest2.t2;
--replace_column 1 # --replace_column 1 #
--sorted_result --sorted_result
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
create table t1 (i int); create table t1 (i int);
drop table t1; drop table t1;
...@@ -235,21 +235,18 @@ create table mysqltest2.t2 like test.t1; ...@@ -235,21 +235,18 @@ create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write; lock table test.t1 write, mysqltest2.t2 write;
--replace_column 1 # --replace_column 1 #
--sorted_result --sorted_result
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
--error ER_DUP_FIELDNAME --error ER_DUP_FIELDNAME
create or replace table test.t1 (a int) select 1 as 'a', 2 as 'a'; create or replace table test.t1 (a int) select 1 as 'a', 2 as 'a';
show tables; show tables;
--replace_column 1 # --replace_column 1 #
--sorted_result --sorted_result
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
--error ER_DUP_FIELDNAME --error ER_DUP_FIELDNAME
create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a'; create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a';
--replace_column 1 # --replace_column 1 #
--sorted_result --sorted_result
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
create table t1 (i int); create table t1 (i int);
drop table t1; drop table t1;
...@@ -258,8 +255,7 @@ create table mysqltest2.t2 like test.t1; ...@@ -258,8 +255,7 @@ create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write; lock table test.t1 write, mysqltest2.t2 write;
--replace_column 1 # --replace_column 1 #
--sorted_result --sorted_result
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
unlock tables; unlock tables;
drop table test.t1,mysqltest2.t2; drop table test.t1,mysqltest2.t2;
...@@ -268,8 +264,7 @@ create table mysqltest2.t2 like test.t1; ...@@ -268,8 +264,7 @@ create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write; lock table test.t1 write, mysqltest2.t2 write;
--replace_column 1 # --replace_column 1 #
--sorted_result --sorted_result
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
unlock tables; unlock tables;
drop table t1; drop table t1;
...@@ -285,15 +280,13 @@ create table t1 (i int); ...@@ -285,15 +280,13 @@ create table t1 (i int);
lock table t1 write; lock table t1 write;
--replace_column 1 # --replace_column 1 #
--sorted_result --sorted_result
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
--error ER_DATA_TOO_LONG --error ER_DATA_TOO_LONG
create or replace table t1 (a char(1)) engine=Innodb select 'foo' as a; create or replace table t1 (a char(1)) engine=Innodb select 'foo' as a;
show tables; show tables;
--replace_column 1 # --replace_column 1 #
--sorted_result --sorted_result
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
create table t1 (i int); create table t1 (i int);
drop table t1; drop table t1;
...@@ -371,24 +364,20 @@ create table t1 (a int); ...@@ -371,24 +364,20 @@ create table t1 (a int);
lock table t1 write, t2 read; lock table t1 write, t2 read;
--replace_column 1 # --replace_column 1 #
--sorted_result --sorted_result
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
create or replace table t1 (i int); create or replace table t1 (i int);
--replace_column 1 # --replace_column 1 #
--sorted_result --sorted_result
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
create or replace table t1 like t2; create or replace table t1 like t2;
--replace_column 1 # --replace_column 1 #
--sorted_result --sorted_result
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
create or replace table t1 select 1 as f1; create or replace table t1 select 1 as f1;
--replace_column 1 # --replace_column 1 #
--sorted_result --sorted_result
select * from information_schema.metadata_lock_info select * from information_schema.metadata_lock_info;
where table_name not like 'innodb_%_stats';
drop table t1; drop table t1;
unlock tables; unlock tables;
...@@ -520,3 +509,5 @@ UNLOCK TABLES; ...@@ -520,3 +509,5 @@ UNLOCK TABLES;
DROP TABLE t3; DROP TABLE t3;
--echo # End of 10.4 tests --echo # End of 10.4 tests
SET GLOBAL innodb_stats_persistent=@save_persistent;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment