Commit 9608773f authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-4750 follow-up: Reduce disabling innodb_stats_persistent

This essentially reverts commit 4e89ec66
and only disables InnoDB persistent statistics for tests where it is
desirable. By design, InnoDB persistent statistics will not be updated
except by ANALYZE TABLE or by STATS_AUTO_RECALC.

The internal transactions that update persistent InnoDB statistics
in background tasks (with innodb_stats_auto_recalc=ON) may cause
nondeterministic query plans or interfere with some tests that deal
with other InnoDB internals, such as the purge of transaction history.
parent 45a05fda
# Copyright (c) 2007, 2013, Oracle and/or its affiliates
# Copyright (c) 2010, 2019, MariaDB Corporation
# Copyright (c) 2010, 2021, 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
......@@ -54,7 +54,6 @@ loose-innodb_write_io_threads= 2
loose-innodb_read_io_threads= 2
loose-innodb_log_buffer_size= 1M
loose-innodb_log_file_size= 10M
loose-innodb-stats-persistent= OFF
slave-net-timeout=120
......
......@@ -28,7 +28,7 @@ SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SH
connection thread1;
# should not crash
SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SHARE MODE;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
Got one of the listed errors
connection thread2;
d
disconnect thread2;
......
......@@ -40,7 +40,7 @@ SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SH
connection thread1;
--echo # should not crash
--error ER_LOCK_DEADLOCK
--error ER_LOCK_DEADLOCK,ER_LOCK_WAIT_TIMEOUT
SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SHARE MODE; #crashes
connection thread2;
......
--skip-innodb-stats-persistent
drop table if exists t1,t2,t3;
CREATE TABLE t2 (a int);
INSERT INTO t2 VALUES(1),(2),(3);
#
......@@ -259,7 +258,8 @@ Note 1051 Unknown table 'test.t1,mysqltest2.t2'
create table test.t1 (i int) engine=myisam;
create table mysqltest2.t2 like test.t1;
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
# MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock
......@@ -272,7 +272,8 @@ ERROR 42000: A table must have at least 1 column
show tables;
Tables_in_test
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
# MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock
......@@ -281,14 +282,16 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2
create or replace table mysqltest2.t2;
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
create table t1 (i int);
drop table t1;
create table test.t1 (i int);
create table mysqltest2.t2 like test.t1;
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
# MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock
......@@ -301,7 +304,8 @@ ERROR 42S21: Duplicate column name 'a'
show tables;
Tables_in_test
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
# MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock
......@@ -310,14 +314,16 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
# 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';
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
create table t1 (i int);
drop table t1;
create table test.t1 (i int) engine=innodb;
create table mysqltest2.t2 like test.t1;
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
# MDL_BACKUP_DDL NULL Backup lock
# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2
......@@ -329,7 +335,8 @@ drop table test.t1,mysqltest2.t2;
create table test.t1 (i int) engine=aria transactional=1 checksum=1;
create table mysqltest2.t2 like test.t1;
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
# MDL_BACKUP_DDL NULL Backup lock
# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2
......@@ -424,7 +431,8 @@ drop view t1;
#
create table t1 (a int);
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
# MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock
......@@ -432,7 +440,8 @@ 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_READ NULL Table metadata lock test t2
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
# MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock
......@@ -440,7 +449,8 @@ 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_READ NULL Table metadata lock test 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
# MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock
......@@ -448,7 +458,8 @@ 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_READ NULL Table metadata lock test t2
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
# MDL_BACKUP_DDL NULL Backup lock
# MDL_BACKUP_DML NULL Backup lock
......
......@@ -4,9 +4,6 @@
--source include/have_innodb.inc
--source include/have_metadata_lock_info.inc
--disable_warnings
drop table if exists t1,t2,t3;
--enable_warnings
#
# Create help table
......@@ -215,18 +212,21 @@ create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write;
--replace_column 1 #
--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
create or replace table test.t1;
show tables;
--replace_column 1 #
--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
create or replace table mysqltest2.t2;
--replace_column 1 #
--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);
drop table t1;
......@@ -235,18 +235,21 @@ create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write;
--replace_column 1 #
--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
create or replace table test.t1 (a int) select 1 as 'a', 2 as 'a';
show tables;
--replace_column 1 #
--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
create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a';
--replace_column 1 #
--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);
drop table t1;
......@@ -255,7 +258,8 @@ create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write;
--replace_column 1 #
--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;
drop table test.t1,mysqltest2.t2;
......@@ -264,7 +268,8 @@ create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write;
--replace_column 1 #
--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;
drop table t1;
......@@ -344,19 +349,24 @@ create table t1 (a int);
lock table t1 write, t2 read;
--replace_column 1 #
--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);
--replace_column 1 #
--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;
--replace_column 1 #
--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;
--replace_column 1 #
--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;
unlock tables;
......
--default-storage-engine=MyISAM
--innodb-stats-persistent=OFF
SET @save_innodb_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=0;
#
# MDEV-16917: do not use splitting for derived with join cache
#
......@@ -241,3 +243,4 @@ set optimizer_switch='split_materialized=default';
set use_stat_tables=default;
set optimizer_use_condition_selectivity=default;
# End of 10.3 tests
SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent;
......@@ -2,6 +2,9 @@
--source include/default_optimizer_switch.inc
--source include/have_sequence.inc
SET @save_innodb_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=0;
--echo #
--echo # MDEV-16917: do not use splitting for derived with join cache
--echo #
......@@ -193,3 +196,5 @@ set use_stat_tables=default;
set optimizer_use_condition_selectivity=default;
--echo # End of 10.3 tests
SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent;
......@@ -162,7 +162,8 @@ nothing
teststring
teststring
drop table t1;
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) engine=innodb;
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) engine=innodb
stats_persistent=0;
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
check table t1;
Table Op Msg_type Msg_text
......
......@@ -74,7 +74,8 @@ drop table t1;
# Test InnoDB tables
#
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) engine=innodb;
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) engine=innodb
stats_persistent=0;
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
check table t1;
select * from t1 where text1='teststring' or text1 like 'teststring_%';
......
......@@ -3,6 +3,8 @@ set global innodb_prefix_index_cluster_optimization = ON;
show variables like 'innodb_prefix_index_cluster_optimization';
Variable_name Value
innodb_prefix_index_cluster_optimization ON
SET @save_innodb_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent = OFF;
# Create a table with a large varchar field that we index the prefix
# of and ensure we only trigger cluster lookups when we expect it.
create table prefixinno (
......@@ -455,3 +457,4 @@ blog_id
1
DROP TABLE wp_blogs;
SET GLOBAL innodb_prefix_index_cluster_optimization = @save_opt;
SET GLOBAL innodb_stats_persistent = @save_innodb_stats_persistent;
......@@ -4,6 +4,9 @@ SET @save_opt= @@GLOBAL.innodb_prefix_index_cluster_optimization;
set global innodb_prefix_index_cluster_optimization = ON;
show variables like 'innodb_prefix_index_cluster_optimization';
SET @save_innodb_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent = OFF;
--echo # Create a table with a large varchar field that we index the prefix
--echo # of and ensure we only trigger cluster lookups when we expect it.
create table prefixinno (
......@@ -717,3 +720,4 @@ AND path IN ( '/fondsinvesteringer/', '/' );
DROP TABLE wp_blogs;
SET GLOBAL innodb_prefix_index_cluster_optimization = @save_opt;
SET GLOBAL innodb_stats_persistent = @save_innodb_stats_persistent;
......@@ -6,6 +6,8 @@ SET DEFAULT_STORAGE_ENGINE = InnoDB;
set @optimizer_switch_save= @@optimizer_switch;
set optimizer_switch='index_merge_sort_intersection=off';
set optimizer_switch='rowid_filter=off';
SET @save_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=0;
#---------------- Index merge test 2 -------------------------------------------
create table t1
(
......@@ -835,3 +837,4 @@ a b c
DROP TABLE t1;
SET sort_buffer_size= @save_sort_buffer_size;
disconnect disable_purge;
SET GLOBAL innodb_stats_persistent=@save_stats_persistent;
......@@ -27,6 +27,9 @@ set @optimizer_switch_save= @@optimizer_switch;
set optimizer_switch='index_merge_sort_intersection=off';
set optimizer_switch='rowid_filter=off';
SET @save_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=0;
# The first two tests are disabled because of non deterministic explain output.
# If include/index_merge1.inc can be enabled for InnoDB and all other
# storage engines, please remove the subtest for Bug#21277 from
......@@ -222,3 +225,4 @@ DROP TABLE t1;
SET sort_buffer_size= @save_sort_buffer_size;
disconnect disable_purge;
SET GLOBAL innodb_stats_persistent=@save_stats_persistent;
......@@ -602,6 +602,17 @@ INSERT INTO t3 VALUES
(89,'text-8008',''),(90,'text-9008',''),(91,'text-9',''),(92,'text-1009',''),
(93,'text-2009',''),(94,'text-3009',''),(95,'text-4009',''),(96,'text-5009',''),
(97,'text-6009',''),(98,'text-7009',''),(99,'text-8009',''),(100,'text-9009','');
ANALYZE TABLE t1,t2,t3;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze Warning Engine-independent statistics are not collected for column 'page_restrictions'
test.t1 analyze status OK
test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status OK
test.t3 analyze status Engine-independent statistics collected
test.t3 analyze Warning Engine-independent statistics are not collected for column 'old_text'
test.t3 analyze Warning Engine-independent statistics are not collected for column 'old_flags'
test.t3 analyze status OK
EXPLAIN
SELECT * FROM t1, t2 IGNORE INDEX (PRIMARY), t3
WHERE page_id=rev_page AND rev_text_id=old_id AND page_namespace=4 AND page_title='Sandbox'
......
......@@ -456,6 +456,7 @@ INSERT INTO t3 VALUES
(89,'text-8008',''),(90,'text-9008',''),(91,'text-9',''),(92,'text-1009',''),
(93,'text-2009',''),(94,'text-3009',''),(95,'text-4009',''),(96,'text-5009',''),
(97,'text-6009',''),(98,'text-7009',''),(99,'text-8009',''),(100,'text-9009','');
ANALYZE TABLE t1,t2,t3;
EXPLAIN
......
SET @save_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=0;
CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
INDEX (name)) ENGINE=InnoDB;
CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11),
......@@ -515,3 +517,4 @@ UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c2 AND t2.c1 = 3 SET t1.c3 = RAND()*10;
COMMIT;
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
DROP TABLE t1,t2;
SET GLOBAL innodb_stats_persistent=@save_stats_persistent;
......@@ -4,6 +4,8 @@
--source include/have_innodb.inc
--source include/default_optimizer_switch.inc
SET @save_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=0;
#
# Test for bug #17164: ORed FALSE blocked conversion of outer join into join
......@@ -391,3 +393,4 @@ COMMIT;
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
DROP TABLE t1,t2;
SET GLOBAL innodb_stats_persistent=@save_stats_persistent;
......@@ -1969,7 +1969,7 @@ rename table mysql.global_priv_bak to mysql.global_priv;
# Check that mysql_upgrade can be run on mysqldump
# of mysql schema from previous versions
#
call mtr.add_suppression("innodb_table_stats has length mismatch in the column name table_name");
call mtr.add_suppression("innodb_(table|index)_stats has length mismatch in the column name table_name");
call mtr.add_suppression("Column count of mysql.proc is wrong. Expected 21, found 20.");
#
# Upgrade from version 5.5
......
......@@ -367,7 +367,7 @@ rename table mysql.global_priv_bak to mysql.global_priv;
--echo #
# The warning appears during mysql_upgrade, before the schema becomes consistent
call mtr.add_suppression("innodb_table_stats has length mismatch in the column name table_name");
call mtr.add_suppression("innodb_(table|index)_stats has length mismatch in the column name table_name");
# This comes from opening 10.6 sys.host_summary view that uses sys.format_time function,
# on still inconsistent mysql.proc, in older versions
call mtr.add_suppression("Column count of mysql.proc is wrong. Expected 21, found 20.");
......
drop table if exists t0,t1,t2,t3;
SET @save_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=OFF;
#
# MDEV-6402: Optimizer doesn't choose best execution plan when composite key is used
#
......@@ -96,3 +97,4 @@ ORDER BY pk2 DESC LIMIT 21;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref key1 key1 55 const,const 1 Using where; Using index
drop table t1, t2;
SET GLOBAL innodb_stats_persistent=@save_stats_persistent;
--source include/have_innodb.inc
--disable_warnings
drop table if exists t0,t1,t2,t3;
--enable_warnings
SET @save_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=OFF;
--echo #
--echo # MDEV-6402: Optimizer doesn't choose best execution plan when composite key is used
......@@ -96,3 +95,4 @@ ORDER BY pk2 DESC LIMIT 21;
drop table t1, t2;
SET GLOBAL innodb_stats_persistent=@save_stats_persistent;
DROP TABLE IF EXISTS t1,t2,t3,t4;
DROP DATABASE IF EXISTS world;
set names utf8;
CREATE DATABASE world;
use world;
......
......@@ -2,11 +2,6 @@
--source include/default_charset.inc
--source include/have_sequence.inc
--disable_warnings
DROP TABLE IF EXISTS t1,t2,t3,t4;
DROP DATABASE IF EXISTS world;
--enable_warnings
set names utf8;
CREATE DATABASE world;
......@@ -1049,6 +1044,8 @@ INSERT INTO t1 VALUES
(0,99083,'all','jhjerdvdxboydmpefbiesqbyyvdftsidjtvulamazljx'),
(32767,99084,'s','flj'),(-4947,99085,'something','Vermont'),
(0,99086,'cjfljhjerd','Washington');
ANALYZE TABLE t1;
--enable_query_log
--enable_result_log
......
......@@ -4,8 +4,6 @@ set @innodb_stats_persistent_sample_pages_save=
@@innodb_stats_persistent_sample_pages;
set global innodb_stats_persistent= 1;
set global innodb_stats_persistent_sample_pages=100;
DROP TABLE IF EXISTS t1,t2,t3,t4;
DROP DATABASE IF EXISTS world;
set names utf8;
CREATE DATABASE world;
use world;
......
SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB';
SET @save_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=0;
DROP DATABASE IF EXISTS dbt3_s001;
CREATE DATABASE dbt3_s001;
use dbt3_s001;
......@@ -2144,13 +2146,14 @@ a b
drop table t1;
SET @@optimizer_switch=@save_optimizer_switch;
set @@use_stat_tables=@save_use_stat_tables;
SET GLOBAL innodb_stats_persistent=@save_stats_persistent;
#
# MDEV-18755: possible RORI-plan and possible plan with range filter
#
create table t1 (
pk int not null primary key, f1 varchar(10), f2 varchar(30), a int(10),
key (f1), key (f2)
) engine=innodb;
) engine=innodb stats_persistent=0;
insert into t1 values
(2,'a','a',2),(3,'a','a',null),(4,'a','a',55),(5,'a','a',4),(6,'a','a',0),
(7,'a','a',1),(8,'a','a',4),(9,'a','a',null),(10,'a','a',0),(11,'a','a',0),
......@@ -2513,7 +2516,7 @@ timestamp timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (id),
KEY ixEventWhoisDomainDomain (domain),
KEY ixEventWhoisDomainTimestamp (timestamp)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB STATS_PERSISTENT=0 DEFAULT CHARSET=utf8;
INSERT INTO t1 (
id, domain, registrant_name, registrant_organization, registrant_street1,
registrant_street2, registrant_street3, registrant_street4, registrant_street5,
......
......@@ -2,7 +2,13 @@
SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB';
SET @save_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=0;
--source rowid_filter.test
SET GLOBAL innodb_stats_persistent=@save_stats_persistent;
--source include/have_sequence.inc
--echo #
......@@ -12,7 +18,7 @@ SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB';
create table t1 (
pk int not null primary key, f1 varchar(10), f2 varchar(30), a int(10),
key (f1), key (f2)
) engine=innodb;
) engine=innodb stats_persistent=0;
insert into t1 values
(2,'a','a',2),(3,'a','a',null),(4,'a','a',55),(5,'a','a',4),(6,'a','a',0),
......@@ -265,7 +271,7 @@ CREATE TABLE t1 (
PRIMARY KEY (id),
KEY ixEventWhoisDomainDomain (domain),
KEY ixEventWhoisDomainTimestamp (timestamp)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB STATS_PERSISTENT=0 DEFAULT CHARSET=utf8;
INSERT INTO t1 (
id, domain, registrant_name, registrant_organization, registrant_street1,
......
SET @save_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=0;
SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB;
drop table if exists t1, t2, t3,t4;
create table t1 (
......@@ -185,3 +187,4 @@ bb b--b 2 2
ccc c--c 2 2
dddd d--d 2 2
drop table t1;
SET GLOBAL innodb_stats_persistent=@save_stats_persistent;
......@@ -10,5 +10,9 @@
--source include/have_innodb.inc
let $engine_type= InnoDB;
SET @save_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=0;
--source include/rowid_order.inc
SET GLOBAL innodb_stats_persistent=@save_stats_persistent;
SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB';
set @save_optimizer_switch_for_selectivity_test=@@optimizer_switch;
set optimizer_switch='extended_keys=on';
SET @save_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=0;
drop table if exists t0,t1,t2,t3;
select @@global.use_stat_tables;
@@global.use_stat_tables
......@@ -2153,3 +2155,4 @@ set use_stat_tables= @tmp_ust;
set optimizer_use_condition_selectivity= @tmp_oucs;
set @@global.histogram_size=@save_histogram_size;
SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT;
SET GLOBAL innodb_stats_persistent=@save_stats_persistent;
......@@ -7,6 +7,8 @@ SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB';
set @save_optimizer_switch_for_selectivity_test=@@optimizer_switch;
set optimizer_switch='extended_keys=on';
SET @save_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=0;
--source selectivity.test
......@@ -233,3 +235,4 @@ set use_stat_tables= @tmp_ust;
set optimizer_use_condition_selectivity= @tmp_oucs;
set @@global.histogram_size=@save_histogram_size;
SET SESSION DEFAULT_STORAGE_ENGINE=DEFAULT;
SET GLOBAL innodb_stats_persistent=@save_stats_persistent;
set global innodb_stats_persistent= 1;
drop table if exists t1;
Warnings:
Note 1051 Unknown table 'test.t1'
create table t1 (
f1 bigint(20) default 0,
f2 varchar(50) default '',
......@@ -49,7 +45,7 @@ f43 varchar(50) default '',
f44 varchar(50) default '',
f45 int(10) default 0,
f46 tinyint(1) default 0
) engine=innodb row_format=dynamic;
) engine=innodb stats_persistent=1 row_format=dynamic;
insert into t1 () values (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),();
insert into t1 select * from t1;
insert into t1 select * from t1;
......@@ -314,4 +310,3 @@ f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 f20 f21 f22 f
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
drop table t1;
set global innodb_stats_persistent= 0;
--source include/have_innodb.inc
set global innodb_stats_persistent= 1;
drop table if exists t1;
create table t1 (
f1 bigint(20) default 0,
f2 varchar(50) default '',
......@@ -48,8 +46,7 @@ create table t1 (
f44 varchar(50) default '',
f45 int(10) default 0,
f46 tinyint(1) default 0
) engine=innodb row_format=dynamic;
) engine=innodb stats_persistent=1 row_format=dynamic;
insert into t1 () values (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),();
insert into t1 select * from t1;
insert into t1 select * from t1;
......@@ -57,4 +54,3 @@ insert into t1 select * from t1;
insert into t1 select * from t1;
select * from t1 where f2 in (select f2 from t1 group by f2 having count(distinct f3) = 1);
drop table t1;
set global innodb_stats_persistent= 0;
set @subselect_innodb_tmp=@@optimizer_switch;
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
drop table if exists t1,t2,t3;
SET @saved_stats_persistent = @@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent = OFF;
CREATE TABLE t1
(
FOLDERID VARCHAR(32)BINARY NOT NULL
......@@ -663,3 +664,4 @@ execute stmt;
a b
drop table t1,t2;
# End of 10.4 tests
SET GLOBAL innodb_stats_persistent = @saved_stats_persistent;
......@@ -4,9 +4,8 @@
# settings are not relevant.
set @subselect_innodb_tmp=@@optimizer_switch;
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
--disable_warnings
drop table if exists t1,t2,t3;
--enable_warnings
SET @saved_stats_persistent = @@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent = OFF;
#
# key field overflow test
......@@ -662,3 +661,5 @@ execute stmt;
drop table t1,t2;
--echo # End of 10.4 tests
SET GLOBAL innodb_stats_persistent = @saved_stats_persistent;
SET @save_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=0;
select 0 + b'1';
0 + b'1'
1
......@@ -34,7 +36,6 @@ select 0 + b'1111111111111111';
select 0 + b'1000000000000001';
0 + b'1000000000000001'
32769
drop table if exists t1;
create table t1 (a bit(65)) engine=innodb;
ERROR 42000: Display width out of range for 'a' (max = 64)
create table t1 (a bit(0)) engine=innodb;
......@@ -422,3 +423,4 @@ hex(f1) hex(f2)
0 0
0 0
drop table t1;
SET GLOBAL innodb_stats_persistent=@save_stats_persistent;
--source include/have_innodb.inc
SET @save_stats_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=0;
#
# testing of the BIT column type
#
......@@ -16,10 +19,6 @@ select 0 + b'1000000000000000';
select 0 + b'1111111111111111';
select 0 + b'1000000000000001';
--disable_warnings
drop table if exists t1;
--enable_warnings
--error 1439
create table t1 (a bit(65)) engine=innodb;
......@@ -157,3 +156,5 @@ insert into t1 (f1) values (default);
insert into t1 values (b'',b''),('','');
select hex(f1), hex(f2) from t1;
drop table t1;
SET GLOBAL innodb_stats_persistent=@save_stats_persistent;
create table t1 (old_c1 integer, old_c2 integer,c1 integer, c2 integer, c3 integer) engine=InnoDb;
create table t1 (old_c1 integer, old_c2 integer,c1 integer, c2 integer, c3 integer) engine=InnoDB STATS_PERSISTENT=0;
create view v1 as select * from t1 where c2=2;
create trigger trg_t1 before update on t1 for each row
begin
......
--source include/have_sequence.inc
--source include/have_innodb.inc
create table t1 (old_c1 integer, old_c2 integer,c1 integer, c2 integer, c3 integer) engine=InnoDb;
create table t1 (old_c1 integer, old_c2 integer,c1 integer, c2 integer, c3 integer) engine=InnoDB STATS_PERSISTENT=0;
create view v1 as select * from t1 where c2=2;
delimiter /;
create trigger trg_t1 before update on t1 for each row
......
SET @save_stats_auto_recalc=@@GLOBAL.innodb_stats_auto_recalc;
SET GLOBAL innodb_stats_auto_recalc=OFF;
set sql_mode="";
SET NAMES 'utf8';
#
......@@ -6372,3 +6374,4 @@ ROLLBACK /* added by mysqlbinlog */;
# Cleanup.
#
DROP TABLE t1;
SET GLOBAL innodb_stats_auto_recalc=@save_stats_auto_recalc;
......@@ -12,6 +12,9 @@
--source include/have_innodb.inc
let $engine_type=InnoDB;
SET @save_stats_auto_recalc=@@GLOBAL.innodb_stats_auto_recalc;
SET GLOBAL innodb_stats_auto_recalc=OFF;
#
# The test case would also work with statement based or mixed mode logging.
# But this would require different result files. To handle this with the
......@@ -22,3 +25,4 @@ let $engine_type=InnoDB;
--source include/mysqlbinlog_row_engine.inc
SET GLOBAL innodb_stats_auto_recalc=@save_stats_auto_recalc;
......@@ -203,7 +203,7 @@ INSERT INTO c ( col_time_nokey,col_datetime_nokey,col_varchar_nokey) values
('16:21:18.052408','2001-11-08 21:02:12.009395', 'x'),
('18:56:33.027423','2003-04-01 00:00:00', 'i');
--replace_column 10 x 11 x
--replace_column 9 x 10 x
EXPLAIN SELECT
outr.col_time_key AS x
FROM c as outr
......
......@@ -507,7 +507,7 @@ INSERT /*! IGNORE */ INTO cc (
(6, '2008-10-10', NULL, '2000-05-22 00:00:00', 'i'),
(8, '2002-01-19', '05:18:40.006865', '2009-02-12 00:00:00', 'v');
--replace_column 10 # 11 #
--replace_column 9 # 10 #
EXPLAIN
SELECT subquery2_t2.col_int_key AS subquery2_field1
FROM (c AS subquery2_t1 RIGHT JOIN
......@@ -544,10 +544,10 @@ CREATE TABLE cc (
KEY (col_int_key)
);
INSERT INTO cc (col_int_nokey) VALUES (0),(1),(7),(0),(4),(5);
--replace_column 10 # 11 #
--replace_column 9 # 10 #
EXPLAIN SELECT pk FROM cc WHERE col_int_key > 3;
SELECT pk FROM cc WHERE col_int_key > 3;
--replace_column 10 # 11 #
--replace_column 9 # 10 #
EXPLAIN SELECT pk FROM cc WHERE col_int_key > 3 ORDER BY 1;
SELECT pk FROM cc WHERE col_int_key > 3 ORDER BY 1;
DROP TABLE cc;
......@@ -601,7 +601,7 @@ INSERT INTO a (
ANALYZE TABLE a, c;
--replace_column 10 #
--replace_column 9 #
--disable_warnings
EXPLAIN
SELECT
......@@ -675,7 +675,7 @@ col_varchar_nokey
(5, 'b'),(8,'m'),(7, 'j'),(2, 'v');
ANALYZE TABLE c, cc;
--replace_column 10 #
--replace_column 9 #
--disable_warnings
let query=SELECT
......@@ -734,7 +734,7 @@ KEY cover_key1 (col_int, col_varchar_255_utf8_key));
INSERT INTO j(col_int, pk, col_varchar_10_utf8) VALUES(9, 1, '951910400'),
(-1934295040, 2, '1235025920'),(-584581120, 3, '-1176633344'),(3, 4, '1074462720');
--replace_column 10 #
--replace_column 9 #
EXPLAIN SELECT col_varchar_255_utf8_key FROM j ORDER BY 1;
SELECT col_varchar_255_utf8_key FROM j ORDER BY col_varchar_255_utf8_key;
......
......@@ -29,20 +29,20 @@ select d,e from v1;
select is_updatable from information_schema.views where table_name='v1';
# view with different algorithms (explain output differs)
--replace_column 10 X
--replace_column 9 X
explain select d,e from v1;
create algorithm=temptable view v2 (d,e) as select abs(b), abs(c) from t1;
show create view v2;
--sorted_result
select d,e from v2;
--replace_column 10 X
--replace_column 9 X
explain select d,e from v2;
# VIEW on VIEW test
create view v3 (d,e) as select d*2, e*2 from v1;
--sorted_result
select * from v3;
--replace_column 10 X
--replace_column 9 X
explain select * from v3;
drop view v1,v2,v3;
......@@ -58,7 +58,7 @@ insert into t1 (a) values (1), (2), (3), (1), (2), (3);
create view v1 as select distinct b from t1;
--sorted_result
select * from v1;
--replace_column 10 X
--replace_column 9 X
explain select * from v1;
--sorted_result
select * from t1;
......@@ -66,7 +66,7 @@ drop view v1;
create view v1 as select distinct c from t1;
--sorted_result
select * from v1;
--replace_column 10 X
--replace_column 9 X
explain select * from v1;
--sorted_result
select * from t1;
......@@ -82,13 +82,13 @@ create table t1 (a int not null,
insert into t1 (a) values (1), (2), (3), (4);
create view v1 as select b+1 from t1 order by 1 desc limit 2;
select * from v1;
--replace_column 10 X
--replace_column 9 X
explain select * from v1;
drop view v1;
create view v1 as select c+1 from t1 order by 1 desc limit 2;
--sorted_result
select * from v1;
--replace_column 10 X
--replace_column 9 X
explain select * from v1;
drop view v1;
drop table t1;
......
......@@ -205,7 +205,7 @@ outr.col_varchar_nokey in ('c', 'x', 'i')
AND (outr.col_time_key IS NULL OR
outr.col_datetime_key = '2009-09-27');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE outr index_merge col_time_key,col_datetime_key col_time_key,col_datetime_key 4,6 NULL 2 x
1 SIMPLE outr index_merge col_time_key,col_datetime_key col_time_key,col_datetime_key 4,6 NULL x x
SELECT
outr.col_time_key AS x
FROM c AS outr
......
......@@ -205,7 +205,7 @@ outr.col_varchar_nokey in ('c', 'x', 'i')
AND (outr.col_time_key IS NULL OR
outr.col_datetime_key = '2009-09-27');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE outr index_merge col_time_key,col_datetime_key col_time_key,col_datetime_key 4,6 NULL 2 x
1 SIMPLE outr index_merge col_time_key,col_datetime_key col_time_key,col_datetime_key 4,6 NULL x x
SELECT
outr.col_time_key AS x
FROM c AS outr
......
......@@ -591,9 +591,9 @@ FROM (c AS subquery2_t1 RIGHT JOIN
(subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key))
ORDER BY subquery2_field1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE subquery2_t2 index NULL col_int_key_2 10 NULL 20 #
1 SIMPLE subquery2_t3 ALL NULL NULL NULL NULL 20 #
1 SIMPLE subquery2_t1 index NULL PRIMARY 4 NULL 20 #
1 SIMPLE subquery2_t2 index NULL col_int_key_2 10 NULL # #
1 SIMPLE subquery2_t3 ALL NULL NULL NULL NULL # #
1 SIMPLE subquery2_t1 index NULL PRIMARY 4 NULL # #
SELECT subquery2_t2.col_int_key AS subquery2_field1
FROM (c AS subquery2_t1 RIGHT JOIN
(c AS subquery2_t2 LEFT JOIN cc AS subquery2_t3 ON
......@@ -794,7 +794,7 @@ KEY (col_int_key)
INSERT INTO cc (col_int_nokey) VALUES (0),(1),(7),(0),(4),(5);
EXPLAIN SELECT pk FROM cc WHERE col_int_key > 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cc range col_int_key col_int_key 5 NULL 3 #
1 SIMPLE cc range col_int_key col_int_key 5 NULL # #
SELECT pk FROM cc WHERE col_int_key > 3;
pk
5
......@@ -802,7 +802,7 @@ pk
3
EXPLAIN SELECT pk FROM cc WHERE col_int_key > 3 ORDER BY 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cc range col_int_key col_int_key 5 NULL 3 #
1 SIMPLE cc range col_int_key col_int_key 5 NULL # #
SELECT pk FROM cc WHERE col_int_key > 3 ORDER BY 1;
pk
3
......@@ -876,12 +876,12 @@ ON (table3.col_int_key = table2.col_int_key ) ) )
ON (table3.col_int_nokey = table2.pk ) )
GROUP BY field1, field2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY table1 system NULL NULL NULL NULL 1 #
1 PRIMARY table2 ALL PRIMARY,col_int_key,col_int_key_2 NULL NULL NULL 19 #
1 PRIMARY <derived2> ref key0 key0 9 test.table2.pk,test.table2.col_int_key 10 #
2 DERIVED SUBQUERY1_t2 ALL PRIMARY,col_int_key,col_varchar_key,col_int_key_2 NULL NULL NULL 19 #
2 DERIVED SUBQUERY1_t3 ref PRIMARY,col_varchar_key col_varchar_key 5 test.SUBQUERY1_t2.col_varchar_key 1 #
2 DERIVED SUBQUERY1_t1 ALL col_int_key,col_int_key_2 NULL NULL NULL 19 #
1 PRIMARY table1 system NULL NULL NULL NULL #
1 PRIMARY table2 ALL PRIMARY,col_int_key,col_int_key_2 NULL NULL NULL # Using where
1 PRIMARY <derived2> ref key0 key0 9 test.table2.pk,test.table2.col_int_key #
2 DERIVED SUBQUERY1_t2 ALL PRIMARY,col_int_key,col_varchar_key,col_int_key_2 NULL NULL NULL # Using where
2 DERIVED SUBQUERY1_t3 ref PRIMARY,col_varchar_key col_varchar_key 5 test.SUBQUERY1_t2.col_varchar_key #
2 DERIVED SUBQUERY1_t1 ALL col_int_key,col_int_key_2 NULL NULL NULL # Using where; Using join buffer (flat, BNL join)
SELECT
table1.pk AS field1 ,
table1.col_datetime_key AS field2
......@@ -955,10 +955,10 @@ GROUP BY SQ1_field1 , SQ1_field2
)
GROUP BY field1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY alias1 index NULL col_int_key_3 10 NULL 20 #
1 PRIMARY alias2 index NULL col_int_key_2 10 NULL 20 #
2 MATERIALIZED SQ1_alias1 index col_int_key,col_int_key_2,col_int_key_3 col_int_key 5 NULL 20 #
2 MATERIALIZED SQ1_alias2 ALL NULL NULL NULL NULL 20 #
1 PRIMARY alias1 index NULL col_int_key_3 10 NULL # Using index; Using temporary; Using filesort
1 PRIMARY alias2 index NULL col_int_key_2 10 NULL # Using where; Using index; Using join buffer (flat, BNL join)
2 MATERIALIZED SQ1_alias1 index col_int_key,col_int_key_2,col_int_key_3 col_int_key 5 NULL # Using index
2 MATERIALIZED SQ1_alias2 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
SELECT
alias2 . col_varchar_key AS field1
FROM ( cc AS alias1 , cc AS alias2 )
......@@ -1018,7 +1018,7 @@ INSERT INTO j(col_int, pk, col_varchar_10_utf8) VALUES(9, 1, '951910400'),
(-1934295040, 2, '1235025920'),(-584581120, 3, '-1176633344'),(3, 4, '1074462720');
EXPLAIN SELECT col_varchar_255_utf8_key FROM j ORDER BY 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE j index NULL cover_key1 773 NULL 4 #
1 SIMPLE j index NULL cover_key1 773 NULL # Using index; Using filesort
SELECT col_varchar_255_utf8_key FROM j ORDER BY col_varchar_255_utf8_key;
col_varchar_255_utf8_key
-117663334
......
......@@ -20,7 +20,7 @@ is_updatable
NO
explain select d,e from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 X
1 SIMPLE t1 ALL NULL NULL NULL NULL X
create algorithm=temptable view v2 (d,e) as select abs(b), abs(c) from t1;
show create view v2;
View Create View character_set_client collation_connection
......@@ -34,8 +34,8 @@ d e
3 3
explain select d,e from v2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 X
2 DERIVED t1 ALL NULL NULL NULL NULL 5 X
1 PRIMARY <derived2> ALL NULL NULL NULL NULL X
2 DERIVED t1 ALL NULL NULL NULL NULL X
create view v3 (d,e) as select d*2, e*2 from v1;
select * from v3;
d e
......@@ -46,7 +46,7 @@ d e
6 6
explain select * from v3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 X
1 SIMPLE t1 ALL NULL NULL NULL NULL X
drop view v1,v2,v3;
drop table t1;
create table t1 (a int not null,
......@@ -61,8 +61,8 @@ b
-3
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 X
2 DERIVED t1 ALL NULL NULL NULL NULL 6 X
1 PRIMARY <derived2> ALL NULL NULL NULL NULL X
2 DERIVED t1 ALL NULL NULL NULL NULL X Using temporary
select * from t1;
a b c
1 -1 -1
......@@ -80,8 +80,8 @@ c
-3
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 X
2 DERIVED t1 ALL NULL NULL NULL NULL 6 X
1 PRIMARY <derived2> ALL NULL NULL NULL NULL X
2 DERIVED t1 ALL NULL NULL NULL NULL X Using temporary
select * from t1;
a b c
1 -1 -1
......@@ -103,8 +103,8 @@ b+1
-1
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 X
2 DERIVED t1 ALL NULL NULL NULL NULL 4 X
1 PRIMARY <derived2> ALL NULL NULL NULL NULL X
2 DERIVED t1 ALL NULL NULL NULL NULL X Using filesort
drop view v1;
create view v1 as select c+1 from t1 order by 1 desc limit 2;
select * from v1;
......@@ -113,8 +113,8 @@ c+1
0
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 X
2 DERIVED t1 ALL NULL NULL NULL NULL 4 X
1 PRIMARY <derived2> ALL NULL NULL NULL NULL X
2 DERIVED t1 ALL NULL NULL NULL NULL X Using filesort
drop view v1;
drop table t1;
create table t1 (a int,
......
......@@ -20,7 +20,7 @@ is_updatable
NO
explain select d,e from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 X
1 SIMPLE t1 ALL NULL NULL NULL NULL X
create algorithm=temptable view v2 (d,e) as select abs(b), abs(c) from t1;
show create view v2;
View Create View character_set_client collation_connection
......@@ -34,8 +34,8 @@ d e
3 3
explain select d,e from v2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 X
2 DERIVED t1 ALL NULL NULL NULL NULL 5 X
1 PRIMARY <derived2> ALL NULL NULL NULL NULL X
2 DERIVED t1 ALL NULL NULL NULL NULL X
create view v3 (d,e) as select d*2, e*2 from v1;
select * from v3;
d e
......@@ -46,7 +46,7 @@ d e
6 6
explain select * from v3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 X
1 SIMPLE t1 ALL NULL NULL NULL NULL X
drop view v1,v2,v3;
drop table t1;
create table t1 (a int not null,
......@@ -61,8 +61,8 @@ b
-3
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 X
2 DERIVED t1 ALL NULL NULL NULL NULL 6 X
1 PRIMARY <derived2> ALL NULL NULL NULL NULL X
2 DERIVED t1 ALL NULL NULL NULL NULL X Using temporary
select * from t1;
a b c
1 -1 -1
......@@ -80,8 +80,8 @@ c
-3
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 X
2 DERIVED t1 ALL NULL NULL NULL NULL 6 X
1 PRIMARY <derived2> ALL NULL NULL NULL NULL X
2 DERIVED t1 ALL NULL NULL NULL NULL X Using temporary
select * from t1;
a b c
1 -1 -1
......@@ -103,8 +103,8 @@ b+1
-1
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 X
2 DERIVED t1 ALL NULL NULL NULL NULL 4 X
1 PRIMARY <derived2> ALL NULL NULL NULL NULL X
2 DERIVED t1 ALL NULL NULL NULL NULL X Using filesort
drop view v1;
create view v1 as select c+1 from t1 order by 1 desc limit 2;
select * from v1;
......@@ -113,8 +113,8 @@ c+1
0
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 X
2 DERIVED t1 ALL NULL NULL NULL NULL 4 X
1 PRIMARY <derived2> ALL NULL NULL NULL NULL X
2 DERIVED t1 ALL NULL NULL NULL NULL X Using filesort
drop view v1;
drop table t1;
create table t1 (a int,
......
......@@ -2,6 +2,8 @@ set default_storage_engine=innodb;
set @old_dbug=@@global.debug_dbug;
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
SET @saved_stats_persistent = @@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent = OFF;
CREATE TABLE `t` (
`a` BLOB,
`b` BLOB,
......@@ -206,3 +208,4 @@ connection default;
DROP TABLE t1, t2;
set debug_sync=reset;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
SET GLOBAL innodb_stats_persistent = @saved_stats_persistent;
......@@ -8,6 +8,8 @@ set @old_dbug=@@global.debug_dbug;
# Ensure that the history list length will actually be decremented by purge.
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
SET @saved_stats_persistent = @@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent = OFF;
CREATE TABLE `t` (
`a` BLOB,
......@@ -263,3 +265,4 @@ DROP TABLE t1, t2;
set debug_sync=reset;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
SET GLOBAL innodb_stats_persistent = @saved_stats_persistent;
......@@ -17,7 +17,7 @@ innodb_saved_page_number_debug 0
connect stop_purge,localhost,root,,;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connection default;
create table t1 (f1 int primary key, f2 blob) engine=innodb;
create table t1 (f1 int primary key, f2 blob) engine=innodb stats_persistent=0;
start transaction;
insert into t1 values(1, repeat('#',12));
insert into t1 values(2, repeat('+',12));
......
call mtr.add_suppression("InnoDB: Cannot add field .* in table");
SET @save_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
# Test 1) Show the page size from Information Schema
SELECT variable_value FROM information_schema.global_status
WHERE LOWER(variable_name) = 'innodb_page_size';
......@@ -164,13 +166,15 @@ INSERT INTO t2 VALUES ('jejdkrun87'),('adfd72nh9k'),
CREATE TABLE t1(a int, b blob, c text, d text NOT NULL)
ENGINE=innodb DEFAULT CHARSET=utf8;
INSERT INTO t1
SELECT a,LEFT(REPEAT(d,100*a),65535),REPEAT(d,20*a),d FROM t2,t3;
SELECT a,LEFT(REPEAT(d,100*a),65535),REPEAT(d,20*a),d FROM t2,t3
ORDER BY a,d;
DROP TABLE t2, t3;
SELECT COUNT(*) FROM t1 WHERE a=44;
COUNT(*)
5
SELECT a,
LENGTH(b),b=LEFT(REPEAT(d,100*a),65535),LENGTH(c),c=REPEAT(d,20*a),d FROM t1;
LENGTH(b),b=LEFT(REPEAT(d,100*a),65535),LENGTH(c),c=REPEAT(d,20*a),d FROM t1
ORDER BY a,d;
a LENGTH(b) b=LEFT(REPEAT(d,100*a),65535) LENGTH(c) c=REPEAT(d,20*a) d
22 22000 1 4400 1 adfd72nh9k
22 35200 1 7040 1 adfdijn0loKNHJik
......@@ -211,7 +215,8 @@ SELECT COUNT(*) FROM t1 WHERE a=44;
COUNT(*)
5
SELECT a,
LENGTH(b), b=LEFT(REPEAT(d,100*a), 65535),LENGTH(c), c=REPEAT(d,20*a), d FROM t1;
LENGTH(b), b=LEFT(REPEAT(d,100*a), 65535),LENGTH(c), c=REPEAT(d,20*a), d FROM t1
ORDER BY a,d;
a LENGTH(b) b=LEFT(REPEAT(d,100*a), 65535) LENGTH(c) c=REPEAT(d,20*a) d
22 22000 1 4400 1 adfd72nh9k
22 35200 1 7040 1 adfdijn0loKNHJik
......@@ -498,7 +503,9 @@ ERROR 42000: Row size too large (> 8126). Changing some columns to TEXT or BLOB
CREATE TABLE t1(c text, PRIMARY KEY (c(438)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
INSERT INTO t1 VALUES(REPEAT('A',512)),(REPEAT('B',512));
InnoDB 0 transactions not purged
DROP TABLE t1;
DROP TABLE t1_purge, t2_purge, t3_purge, t4_purge;
DROP TABLE tlong;
DROP TABLE tlong2;
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
call mtr.add_suppression("Innodb: Cannot add field.*row size is");
# Test 1) Show the page size from Information Schema
SELECT variable_value FROM information_schema.global_status
......@@ -283,6 +284,7 @@ Level Code Message
UPDATE t3 SET c = REPEAT('b',32800);
SHOW WARNINGS;
Level Code Message
InnoDB 0 transactions not purged
DROP TABLE t3;
DROP TABLE t1_purge, t2_purge, t3_purge, t4_purge;
DROP TABLE tlong;
......
......@@ -45,7 +45,7 @@ set DEBUG_SYNC="now WAIT_FOR default_signal";
disconnect con1;
SHOW KEYS FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored
t1 1 f1 1 f1 A 2 NULL NULL BTREE NO
t1 1 f1 1 f1 A # NULL NULL BTREE NO
DROP TABLE t1;
#
# MDEV-25503 InnoDB hangs on startup during recovery
......
......@@ -24,6 +24,10 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref my_d my_d 5 const 128 Using index
ALTER TABLE t1 DROP INDEX my_d;
ALTER TABLE t1 MODIFY COLUMN D INT;
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
ALTER TABLE t1 ADD INDEX my_d (D);
EXPLAIN SELECT d FROM t1 WHERE d = 5;
id select_type table type possible_keys key key_len ref rows Extra
......
......@@ -148,6 +148,9 @@ database_name table_name index_name last_update stat_name stat_value sample_size
test t1 PRIMARY LAST_UPDATE n_diff_pfx01 5 1 c1
test t1 PRIMARY LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index
test t1 PRIMARY LAST_UPDATE size 1 NULL Number of pages in the index
test t1_c2_stats GEN_CLUST_INDEX LAST_UPDATE n_diff_pfx01 3 1 DB_ROW_ID
test t1_c2_stats GEN_CLUST_INDEX LAST_UPDATE n_leaf_pages 1 NULL Number of leaf pages in the index
test t1_c2_stats GEN_CLUST_INDEX LAST_UPDATE size 1 NULL Number of pages in the index
connection con1;
KILL QUERY @id;
ERROR 70100: Query execution was interrupted
......
......@@ -939,40 +939,40 @@ COUNT(*)
#
EXPLAIN SELECT * FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 12 #
1 SIMPLE t1 ALL NULL NULL NULL NULL #
EXPLAIN SELECT COUNT(*) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL k2 5 NULL 12 Using index
1 SIMPLE t1 index NULL k2 5 NULL # Using index
EXPLAIN SELECT COUNT(c1) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL k2 5 NULL 12 Using index
1 SIMPLE t1 index NULL k2 5 NULL # Using index
EXPLAIN SELECT COUNT(c2) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL k2 5 NULL 12 #
1 SIMPLE t1 index NULL k2 5 NULL # Using index
EXPLAIN SELECT COUNT(c3) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 12 #
1 SIMPLE t1 ALL NULL NULL NULL NULL #
EXPLAIN SELECT SUM(c1) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL k2 5 NULL 12 #
1 SIMPLE t1 index NULL k2 5 NULL # Using index
EXPLAIN SELECT SUM(c2) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL k2 5 NULL 12 #
1 SIMPLE t1 index NULL k2 5 NULL # Using index
EXPLAIN SELECT AVG(c1), MAX(c1), MIN(c2), AVG(c3), SUM(c4) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 12 #
1 SIMPLE t1 ALL NULL NULL NULL NULL #
EXPLAIN SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 8 #
2 SUBQUERY t1 index NULL k2 5 NULL 12 #
1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL # Using where
2 SUBQUERY t1 index NULL k2 5 NULL # Using index
EXPLAIN SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 8 #
2 SUBQUERY t1 index NULL k2 5 NULL 12 #
1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL # Using where
2 SUBQUERY t1 index NULL k2 5 NULL # Using index
EXPLAIN SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 7 #
2 SUBQUERY t1 index NULL k2 5 NULL 12 #
1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL # Using where; Using index
2 SUBQUERY t1 index NULL k2 5 NULL # Using index
#
# Make all indexes in t2 obsolete to the active repeatable read transaction
# in the default connection.
......@@ -1395,11 +1395,11 @@ disconnect con3;
CREATE TABLE t1(c1 INT NOT NULL PRIMARY KEY,
c2 INT NOT NULL DEFAULT 1,
c3 char(20) DEFAULT '',
KEY c2_idx (c2)) ENGINE=InnoDB;
KEY c2_idx (c2)) ENGINE=InnoDB STATS_PERSISTENT=0;
INSERT INTO t1(c1) VALUES (1), (2), (3);
INSERT INTO t1(c1) SELECT c1 + 10 FROM t1;
INSERT INTO t1(c1) SELECT c1 + 100 FROM t1;
CREATE TABLE t2 SELECT * FROM t1;
CREATE TABLE t2 STATS_PERSISTENT=0 SELECT * FROM t1;
EXPLAIN SELECT COUNT(*) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL c2_idx 4 NULL 12 Using index
......
......@@ -8,6 +8,7 @@ call mtr.add_suppression("InnoDB: Page 0 at offset 0 looks corrupted in file");
call mtr.add_suppression("InnoDB: Page for tablespace ");
call mtr.add_suppression("InnoDB: Invalid FSP_SPACE_FLAGS=");
call mtr.add_suppression("InnoDB: Unknown index id .* on page");
call mtr.add_suppression("InnoDB: Cannot save statistics for table `test`\\.`t1` because the \\.ibd file is missing");
FLUSH TABLES;
SET GLOBAL innodb_file_per_table = 1;
CREATE TABLE t1 (c1 INT) ENGINE = InnoDB;
......
call mtr.add_suppression("InnoDB: Unable to import tablespace .* because it already exists. Please DISCARD the tablespace before IMPORT\\.");
call mtr.add_suppression("Index for table 't2' is corrupt; try to repair it");
call mtr.add_suppression("InnoDB: Cannot save statistics for table `test`\\.`t1` because the \\.ibd file is missing");
FLUSH TABLES;
CREATE TABLE t1
(a INT AUTO_INCREMENT PRIMARY KEY,
......
......@@ -45,7 +45,7 @@ level tinyint(4) DEFAULT '0' NOT NULL,
PRIMARY KEY (id),
KEY parent_id (parent_id),
KEY level (level)
) engine=innodb;
) engine=innodb stats_persistent=0;
INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2);
update t1 set parent_id=parent_id+100;
select * from t1 where parent_id=102;
......
......@@ -29,7 +29,7 @@ END~~
# Create a table with one record in it and start an RR transaction
#
CREATE TABLE t1 (a INT, b INT, c INT, PRIMARY KEY(a,b), KEY (b,c))
ENGINE=InnoDB;
ENGINE=InnoDB STATS_PERSISTENT=0;
BEGIN;
SELECT * FROM t1;
a b c
......
select @@global.innodb_stats_persistent;
@@global.innodb_stats_persistent
0
1
set global innodb_defragment_stats_accuracy = 20;
CREATE TABLE t1(a INT PRIMARY KEY, b VARCHAR(256), KEY SECOND(a, b))
ENGINE=INNODB;
......@@ -116,7 +116,6 @@ select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't
count(stat_value) > 0
1
# Clean up
ALTER TABLE t2 STATS_PERSISTENT=1;
DROP TABLE t2;
select * from mysql.innodb_index_stats where table_name = 't2';
database_name table_name index_name last_update stat_name stat_value sample_size stat_description
......@@ -578,7 +578,7 @@ set global innodb_monitor_reset_all = default;
# Bug#22576241 SETTING INNODB_MONITOR_ENABLE TO ALL DOES NOT ENABLE ALL
# MONITORS
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=0;
SELECT NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME
LIKE 'buffer_page_written_index_leaf';
NAME COUNT > 0
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
--skip-innodb-stats-persistent
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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