Commit 228b7e4d authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-13626 Merge InnoDB test cases from MySQL 5.7

This imports and adapts a number of MySQL 5.7 test cases that are
applicable to MariaDB.

Some tests for old bug fixes are not that relevant because the code
has been refactored since then (especially starting with
MariaDB Server 10.6), and the tests would not reproduce the
original bug if the fix was reverted.

In the test innodb_fts.opt, there are many duplicate MATCH ranks, which
would make the results nondeterministic. The test was stabilized by
changing some LIMIT clauses or by adding sorted_result in those cases
where the purpose of a test was to show that no sorting took place
in the server.

In the test innodb_fts.phrase, MySQL 5.7 would generate FTS_DOC_ID that
are 1 larger than in MariaDB. In innodb_fts.index_table the difference is 2.
This is because in MariaDB, fts_get_next_doc_id() post-increments
cache->next_doc_id, while MySQL 5.7 pre-increments it.

Reviewed by: Thirunarayanan Balathandayuthapani
parent 2447172a
......@@ -13,3 +13,32 @@ key(f1,f2(1))
)ENGINE=INNODB;
REPLACE INTO t1(f3) VALUES (1),(1);
DROP TABLE t1;
#Create and alter table examples for full column index followed by prefix index.
CREATE TABLE t1(
f1 VARCHAR(100),
f2 char(2),
KEY(f1,f2),
KEY(f1(5)))ENGINE=INNODB;
REPLACE INTO t1(f2) VALUES (1),(1);
ALTER TABLE t1 ADD INDEX(f2,f1);
DROP TABLE t1;
#Create and alter table examples for small prefix index followed by large
#prefix index.
CREATE TABLE t1(
f1 VARCHAR(100),
f2 char(2),
KEY(f1(5),f2),
KEY(f1(10)))ENGINE=INNODB;
REPLACE INTO t1(f2) VALUES (1),(1);
ALTER TABLE t1 ADD INDEX(f2,f1);
DROP TABLE t1;
#Create and alter table examples for prefix index followed by full column
#index.
CREATE TABLE t1(
f1 VARCHAR(100),
f2 char(2),
KEY(f1(5),f2),
KEY(f1))ENGINE=INNODB;
REPLACE INTO t1(f2) VALUES (1),(1);
ALTER TABLE t1 ADD INDEX(f2,f1);
DROP TABLE t1;
......@@ -20,3 +20,46 @@ REPLACE INTO t1(f3) VALUES (1),(1);
DROP TABLE t1;
--echo #Create and alter table examples for full column index followed by prefix index.
CREATE TABLE t1(
f1 VARCHAR(100),
f2 char(2),
KEY(f1,f2),
KEY(f1(5)))ENGINE=INNODB;
REPLACE INTO t1(f2) VALUES (1),(1);
ALTER TABLE t1 ADD INDEX(f2,f1);
DROP TABLE t1;
--echo #Create and alter table examples for small prefix index followed by large
--echo #prefix index.
CREATE TABLE t1(
f1 VARCHAR(100),
f2 char(2),
KEY(f1(5),f2),
KEY(f1(10)))ENGINE=INNODB;
REPLACE INTO t1(f2) VALUES (1),(1);
ALTER TABLE t1 ADD INDEX(f2,f1);
DROP TABLE t1;
--echo #Create and alter table examples for prefix index followed by full column
--echo #index.
CREATE TABLE t1(
f1 VARCHAR(100),
f2 char(2),
KEY(f1(5),f2),
KEY(f1))ENGINE=INNODB;
REPLACE INTO t1(f2) VALUES (1),(1);
ALTER TABLE t1 ADD INDEX(f2,f1);
DROP TABLE t1;
#
# Bug #19471516 SERVER CRASHES WHEN EXECUTING ALTER TABLE ADD
# FOREIGN KEY
#
CREATE TABLE `parent` (`parent_id` INT, PRIMARY KEY (`parent_id`));
CREATE TABLE `child1` (`id` INT ,`child1_fk1` INT, `child1_fk2` INT,
PRIMARY KEY (`id`));
CREATE TABLE `child2` (`id` INT, `child2_fk1` INT, `child2_fk2` INT,
PRIMARY KEY (`id`));
CREATE TABLE `child3` (`id` INT , `child3_fk1` INT, PRIMARY KEY (`id`));
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk1`) REFERENCES `parent`
(`parent_id`);
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk1`) REFERENCES
`parent` (`parent_id`);
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk2`) REFERENCES `parent`
(`parent_id`);
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk1`) REFERENCES `parent`
(`parent_id`);
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk2`) REFERENCES `parent`
(`parent_id`);
ALTER TABLE `child3` ADD FOREIGN KEY (`child3_fk1`) REFERENCES `parent`
(`parent_id`);
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk2`) REFERENCES
`parent` (`parent_id`);
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk1`) REFERENCES
`parent` (`parent_id`);
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk2`) REFERENCES
`parent` (`parent_id`);
ALTER TABLE `child3` ADD FOREIGN KEY (`child3_fk1`) REFERENCES
`parent` (`parent_id`);
drop table child3, child2, child1, parent;
create table t1 (f1 int primary key) engine=innodb;
create table t2 (f1 int primary key,
constraint c1 foreign key (f1) references t1(f1)
on update cascade
on delete cascade) engine=innodb;
create table t3 (f1 int primary key,
constraint c2 foreign key (f1) references t1(f1)
on update cascade
on delete cascade) engine=innodb;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) NOT NULL,
PRIMARY KEY (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`f1` int(11) NOT NULL,
PRIMARY KEY (`f1`),
CONSTRAINT `c1` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`f1` int(11) NOT NULL,
PRIMARY KEY (`f1`),
CONSTRAINT `c2` FOREIGN KEY (`f1`) REFERENCES `t1` (`f1`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
insert into t1 values (1);
insert into t1 values (2);
insert into t1 values (3);
insert into t2 values (1);
insert into t2 values (2);
insert into t2 values (3);
insert into t3 values (1);
insert into t3 values (2);
insert into t3 values (3);
select f1 from t1;
f1
1
2
3
select f1 from t2;
f1
1
2
3
select f1 from t3;
f1
1
2
3
set @save_dbug = @@debug_dbug;
set debug_dbug = '+d,dml_cascade_only_once';
set debug_dbug = '+d,row_upd_cascade_lock_wait_err';
update t1 set f1 = 100 where f1 = 2;
select f1 from t1;
f1
1
3
100
select f1 from t2;
f1
1
3
100
select f1 from t3;
f1
1
3
100
set debug_dbug = @save_dbug;
drop table t2;
drop table t3;
drop table t1;
SET @old_innodb_file_per_table = @@innodb_file_per_table;
SET GLOBAL innodb_file_per_table = 1;
SELECT @@innodb_file_per_table;
@@innodb_file_per_table
1
CREATE TABLE t1 (
col_1 CHAR (255),
col_2 VARCHAR (255)
) ENGINE = InnoDB;
CREATE INDEX idx1 ON t1(col_1);
CREATE INDEX idx2 ON t1(col_2);
SHOW INDEXES FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 idx1 1 col_1 A 0 NULL NULL YES BTREE
t1 1 idx2 1 col_2 A 0 NULL NULL YES BTREE
INSERT INTO t1 VALUES ("col1_00001", "col2_00001"), ("col1_00002", "col2_00002");
SHOW INDEXES FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE
t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SHOW INDEXES FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE
t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE
FLUSH TABLES t1 FOR EXPORT;
backup: t1
UNLOCK TABLES;
DROP TABLE t1;
CREATE TABLE t1 (
col_1 CHAR (255),
col_2 VARCHAR (255)
) ENGINE = InnoDB STATS_PERSISTENT=1;
CREATE INDEX idx1 ON t1(col_1);
CREATE INDEX idx2 ON t1(col_2);
SHOW INDEXES FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 idx1 1 col_1 A 0 NULL NULL YES BTREE
t1 1 idx2 1 col_2 A 0 NULL NULL YES BTREE
INSERT INTO t1 VALUES ("col1_00001", "col2_00001");
SHOW INDEXES FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 idx1 1 col_1 A 1 NULL NULL YES BTREE
t1 1 idx2 1 col_2 A 1 NULL NULL YES BTREE
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
SHOW INDEXES FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 idx1 1 col_1 A 1 NULL NULL YES BTREE
t1 1 idx2 1 col_2 A 1 NULL NULL YES BTREE
ALTER TABLE t1 DISCARD TABLESPACE;
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
SHOW INDEXES FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE
t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
SHOW INDEXES FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE
t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE
DROP TABLE t1;
SET GLOBAL innodb_file_per_table = @old_innodb_file_per_table;
connect stop_purge,localhost,root;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connection default;
CREATE TABLE t1(a INT PRIMARY KEY, b VARCHAR(1024))
ENGINE=InnoDB STATS_PERSISTENT=1;
INSERT INTO t1 VALUES (1,REPEAT('b',1024));
SELECT index_length FROM information_schema.tables
WHERE table_schema = 'test' AND table_name = 't1';
index_length
0
ALTER TABLE t1 ADD INDEX b (b(800));
SELECT FLOOR(index_length/@@innodb_page_size) FROM information_schema.tables
WHERE table_schema = 'test' AND table_name = 't1';
FLOOR(index_length/@@innodb_page_size)
1
ALTER TABLE t1 ADD INDEX ba (b(800),a);
SELECT FLOOR(index_length/@@innodb_page_size) FROM information_schema.tables
WHERE table_schema = 'test' AND table_name = 't1';
FLOOR(index_length/@@innodb_page_size)
2
disconnect stop_purge;
DROP TABLE t1;
# End of 10.4 tests
call mtr.add_suppression("Innodb: Cannot add field.*row size is");
SET SESSION innodb_strict_mode=ON;
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB KEY_BLOCK_SIZE=4;
ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
SET SESSION innodb_strict_mode=OFF;
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
Warnings:
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
SHOW WARNINGS;
Level Code Message
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
DROP TABLE t1;
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB KEY_BLOCK_SIZE=4;
Warnings:
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
SHOW WARNINGS;
Level Code Message
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
DROP TABLE t1;
# Test 1) Show the page size from Information Schema
SELECT variable_value FROM information_schema.global_status
WHERE LOWER(variable_name) = 'innodb_page_size';
......
call mtr.add_suppression('InnoDB: Cannot add field.*because after adding it, the row size is');
SET SESSION innodb_strict_mode=ON;
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB KEY_BLOCK_SIZE=4;
ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
SET SESSION innodb_strict_mode=OFF;
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
Warnings:
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
SHOW WARNINGS;
Level Code Message
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
DROP TABLE t1;
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB KEY_BLOCK_SIZE=4;
Warnings:
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
SHOW WARNINGS;
Level Code Message
Warning 1478 InnoDB: Cannot create a COMPRESSED table when innodb_page_size > 16k. Assuming ROW_FORMAT=DYNAMIC.
DROP TABLE t1;
# Test 1) Show the page size from Information Schema
SELECT variable_value FROM information_schema.global_status
WHERE LOWER(variable_name) = 'innodb_page_size';
......
CREATE TABLE t1 (c1 INT , c2 CHAR(10), PRIMARY KEY (c1)) ENGINE = InnoDB;
INSERT INTO t1 VALUES(0, "0");
INSERT INTO t1 VALUES(1, "1");
INSERT INTO t1 VALUES(2, "2");
INSERT INTO t1 VALUES(3, "3");
connect con1,localhost,root,,;
connect con2,localhost,root,,;
connect con3,localhost,root,,;
connect con4,localhost,root,,;
connect con5,localhost,root,,;
connect con6,localhost,root,,;
connection default;
SET AUTOCOMMIT=0;
BEGIN;
SELECT * FROM t1 FOR UPDATE;
c1 c2
0 0
1 1
2 2
3 3
SELECT * FROM t1 WHERE c1 <= 3;
c1 c2
0 0
1 1
2 2
3 3
connection default;
SET DEBUG_SYNC='now WAIT_FOR waiting4';
SET DEBUG_SYNC= 'RESET';
SELECT trx_state, trx_query, trx_autocommit_non_locking
FROM INFORMATION_SCHEMA.INNODB_TRX
WHERE trx_state = 'LOCK WAIT'
ORDER BY trx_query;
trx_state trx_query trx_autocommit_non_locking
LOCK WAIT SELECT COUNT(*) FROM t1 LOCK IN SHARE MODE 0
LOCK WAIT SELECT COUNT(*) FROM t1 WHERE c1 >= 0 0
INSERT INTO t1 VALUES(4, '4');
COMMIT;
connection con6;
SELECT * FROM t1 WHERE c1 <= 4;
c1 c2
0 0
1 1
2 2
3 3
XA END '1';
XA PREPARE '1';
XA ROLLBACK '1';
disconnect con6;
disconnect con2;
disconnect con3;
disconnect con5;
connection con1;
COUNT(*)
5
disconnect con1;
connection con4;
COUNT(*)
5
disconnect con4;
connection default;
DROP TABLE t1;
......@@ -1090,3 +1090,59 @@ ALTER TABLE t1 ADD COLUMN b DATETIME NOT NULL, LOCK=NONE;
# Cleanup
SET @@SQL_MODE= @OLD_SQL_MODE;
DROP TABLE t1;
#
# Bug#20977779 CANNOT IMPORT TABLES CONTAINING PREFIX INDEXES
#
CREATE TABLE t1 (c1 VARCHAR(32), c2 VARCHAR(32), c3 VARCHAR(32),
PRIMARY KEY (c1, c2, c3))
ENGINE=InnoDB;
ALTER TABLE t1 ADD INDEX ind1(c1(5), c2, c3);
ALTER TABLE t1 ADD INDEX ind2(c3, c1(10), c2);
ALTER TABLE t1 ADD INDEX ind3(c2, c3, c1(20));
INSERT INTO t1 VALUES ('Test Data -1', 'Test Data -2', 'Test Data -3');
# Test with 2ndary index having prefix
FLUSH TABLES test.t1 FOR EXPORT;
UNLOCK TABLES;
ALTER TABLE test.t1 DISCARD TABLESPACE;
ALTER TABLE test.t1 IMPORT TABLESPACE;
CHECK TABLE test.t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE test.t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` varchar(32) NOT NULL,
`c2` varchar(32) NOT NULL,
`c3` varchar(32) NOT NULL,
PRIMARY KEY (`c1`,`c2`,`c3`),
KEY `ind1` (`c1`(5),`c2`,`c3`),
KEY `ind2` (`c3`,`c1`(10),`c2`),
KEY `ind3` (`c2`,`c3`,`c1`(20))
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * FROM test.t1;
c1 c2 c3
Test Data -1 Test Data -2 Test Data -3
# Test with PK & 2ndary index with prefix
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c1(5), c2(10), c3(20));
FLUSH TABLES test.t1 FOR EXPORT;
UNLOCK TABLES;
ALTER TABLE test.t1 DISCARD TABLESPACE;
ALTER TABLE test.t1 IMPORT TABLESPACE;
CHECK TABLE test.t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SHOW CREATE TABLE test.t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` varchar(32) NOT NULL,
`c2` varchar(32) NOT NULL,
`c3` varchar(32) NOT NULL,
PRIMARY KEY (`c1`(5),`c2`(10),`c3`(20)),
KEY `ind1` (`c1`(5),`c2`,`c3`),
KEY `ind2` (`c3`,`c1`(10),`c2`),
KEY `ind3` (`c2`,`c3`,`c1`(20))
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * FROM test.t1;
c1 c2 c3
Test Data -1 Test Data -2 Test Data -3
DROP TABLE t1;
......@@ -618,3 +618,39 @@ test/e d a 0
test/fw c a 0
DROP TABLE t2;
DROP TABLE t3;
# Bug #17449901 TABLE DISAPPEARS WHEN ALTERING
# WITH FOREIGN KEY CHECKS OFF
create table t1(f1 int,primary key(f1))engine=innodb;
create table t2(f2 int,f3 int,key t(f2,f3),foreign key(f2) references t1(f1))engine=innodb;
SET foreign_key_checks=0;
drop index t on t2;
drop table t2;
drop table t1;
create table t1(f1 int ,primary key(f1))engine=innodb;
create table t2(f2 int,f3 int, key t(f2),foreign key(f2) references t1(f1))engine=innodb;
SET foreign_key_checks = 0;
alter table t2 drop key t,algorithm=inplace;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`f2` int(11) DEFAULT NULL,
`f3` int(11) DEFAULT NULL,
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t2;
drop table t1;
create table t1(f1 int ,primary key(f1))engine=innodb;
create table t2(f2 int,f3 int, key t(f2),key t1(f2,f3),
foreign key(f2) references t1(f1))engine=innodb;
SET foreign_key_checks = 0;
alter table t2 drop key t,algorithm=inplace;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`f2` int(11) DEFAULT NULL,
`f3` int(11) DEFAULT NULL,
KEY `t1` (`f2`,`f3`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t2;
drop table t1;
#
# Bug #21025880 DUPLICATE UK VALUES IN READ-COMMITTED(AGAIN)
#
SET @save_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
CREATE TABLE t1 (
a INT NOT NULL,
b INT NOT NULL,
PRIMARY KEY(b),
UNIQUE KEY(a))
ENGINE=INNODB;
SET @old_innodb_stats_auto_recalc = @@innodb_stats_auto_recalc;
SET GLOBAL innodb_stats_auto_recalc = OFF;
connect purge_control,localhost,root;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connection default;
SET @old_tx_isolation = @@tx_isolation;
SET GLOBAL tx_isolation = 'READ-COMMITTED';
SET @old_innodb_lock_wait_timeout = @@innodb_lock_wait_timeout;
SET GLOBAL innodb_lock_wait_timeout = 1;
connect con1,localhost,root,,;
INSERT INTO t1 VALUES (1,1),(2,2);
DELETE FROM t1;
SET debug_sync = 'row_ins_sec_index_entry_dup_locks_created SIGNAL
con1_locks_done WAIT_FOR con1_go';
SET debug_sync = 'ha_commit_trans_after_acquire_commit_lock SIGNAL
con1_insert_done WAIT_FOR con1_finish';
REPLACE INTO t1 VALUES (1,2);
connect con2,localhost,root,,;
SET debug_sync = 'now WAIT_FOR con1_locks_done';
SET debug_sync = 'lock_wait_suspend_thread_enter SIGNAL con2_blocked
WAIT_FOR con2_go';
SET debug_sync = 'ha_commit_trans_after_acquire_commit_lock
WAIT_FOR con2_finish';
SET debug_sync = 'ib_after_row_insert SIGNAL con2_insert_done';
REPLACE INTO t1 VALUES (1,3);
connection default;
SET debug_sync = 'now WAIT_FOR con2_blocked';
connection purge_control;
COMMIT;
disconnect purge_control;
connection default;
InnoDB 0 transactions not purged
SET debug_sync = 'now SIGNAL con2_go WAIT_FOR con2_insert_done';
SET debug_sync = 'now SIGNAL con1_go WAIT_FOR con1_insert_done';
SET debug_sync = 'now SIGNAL con1_finish';
connection con1;
disconnect con1;
connection default;
SET debug_sync = 'now SIGNAL con2_finish';
connection con2;
disconnect con2;
connection default;
SET DEBUG_SYNC= 'RESET';
SELECT * FROM t1;
a b
1 2
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
SET GLOBAL innodb_stats_auto_recalc = @old_innodb_stats_auto_recalc;
SET GLOBAL tx_isolation = @old_tx_isolation;
SET GLOBAL innodb_lock_wait_timeout = @old_innodb_lock_wait_timeout;
CREATE TABLE t1 (
a INT NOT NULL,
b INT NOT NULL,
PRIMARY KEY(b),
UNIQUE KEY(a))
ENGINE=INNODB;
SET @old_innodb_stats_auto_recalc = @@innodb_stats_auto_recalc;
SET GLOBAL innodb_stats_auto_recalc = OFF;
connect purge_control,localhost,root;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connection default;
SET @old_tx_isolation = @@tx_isolation;
SET GLOBAL tx_isolation = 'READ-COMMITTED';
SET @old_innodb_lock_wait_timeout = @@innodb_lock_wait_timeout;
SET GLOBAL innodb_lock_wait_timeout = 1;
connect con1,localhost,root,,;
INSERT INTO t1 VALUES (1,1),(2,2);
DELETE FROM t1;
SET debug_sync = 'row_ins_sec_index_entry_dup_locks_created SIGNAL
con1_locks_done WAIT_FOR con1_go';
SET debug_sync = 'ha_commit_trans_after_acquire_commit_lock SIGNAL
con1_insert_done WAIT_FOR con1_finish';
INSERT INTO t1 values (1,2) ON DUPLICATE KEY UPDATE a=2;
connect con2,localhost,root,,;
SET debug_sync = 'now WAIT_FOR con1_locks_done';
SET debug_sync = 'lock_wait_suspend_thread_enter SIGNAL con2_blocked
WAIT_FOR con2_go';
SET debug_sync = 'ha_commit_trans_after_acquire_commit_lock
WAIT_FOR con2_finish';
SET debug_sync = 'ib_after_row_insert SIGNAL con2_insert_done';
REPLACE INTO t1 VALUES (1,3);
connection default;
SET debug_sync = 'now WAIT_FOR con2_blocked';
connection purge_control;
COMMIT;
disconnect purge_control;
connection default;
InnoDB 0 transactions not purged
SET debug_sync = 'now SIGNAL con2_go WAIT_FOR con2_insert_done';
SET debug_sync = 'now SIGNAL con1_go WAIT_FOR con1_insert_done';
SET debug_sync = 'now SIGNAL con1_finish';
connection con1;
disconnect con1;
connection default;
SET debug_sync = 'now SIGNAL con2_finish';
connection con2;
disconnect con2;
connection default;
SET DEBUG_SYNC= 'RESET';
SELECT * FROM t1;
a b
1 2
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
SET GLOBAL innodb_stats_auto_recalc = @old_innodb_stats_auto_recalc;
SET GLOBAL tx_isolation = @old_tx_isolation;
SET GLOBAL innodb_lock_wait_timeout = @old_innodb_lock_wait_timeout;
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
......@@ -9,9 +9,6 @@ INSERT INTO t2 VALUES(1, "b");
INSERT INTO t2 VALUES(2, "c");
INSERT INTO t2 VALUES(3, "d");
connect con1,localhost,root,,;
connect con2,localhost,root,,;
connection con1;
'T1'
SET AUTOCOMMIT=0;
BEGIN;
SELECT * FROM t2;
......@@ -21,7 +18,6 @@ c1 c2
2 c
3 d
connection default;
'T2'
SET AUTOCOMMIT=0;
BEGIN;
SELECT * FROM t1;
......@@ -30,8 +26,7 @@ c1 c2
1 1
2 2
3 3
connection con2;
'T3'
connect con2,localhost,root,,;
SET AUTOCOMMIT=0;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
BEGIN;
......@@ -48,7 +43,6 @@ c1 c2
2 c
3 d
connection con1;
'T1'
UPDATE t2 SET c1 = c1 + 100;
SELECT * FROM t2;
c1 c2
......@@ -58,7 +52,6 @@ c1 c2
103 d
COMMIT;
connection default;
'T2'
UPDATE t1 SET c1 = c1 + 100;
SELECT * FROM t1;
c1 c2
......@@ -68,42 +61,29 @@ c1 c2
103 3
COMMIT;
connection con2;
'T3'
SET DEBUG_SYNC='row_search_for_mysql_before_return WAIT_FOR waiting1';
SELECT * FROM t1;;
connection default;
'T2'
SET DEBUG_SYNC='now SIGNAL waiting1';
'Signalled T3'
connection con2;
'T3'
c1 c2
0 0
1 1
2 2
3 3
connection con2;
'T3'
SET DEBUG_SYNC='row_search_for_mysql_before_return WAIT_FOR waiting1';
SELECT * FROM t2;;
connection default;
'T2'
SET DEBUG_SYNC='now SIGNAL waiting1';
'Signalled T3'
connection con2;
'T3'
c1 c2
0 a
1 b
2 c
3 d
connection default;
disconnect con1;
disconnect con2;
connect con1,localhost,root,,;
connect con2,localhost,root,,;
connection con1;
'T1'
SET AUTOCOMMIT=0;
BEGIN;
SELECT * FROM t1;
......@@ -113,7 +93,6 @@ c1 c2
102 2
103 3
connection default;
'T2'
SET AUTOCOMMIT=0;
BEGIN;
SELECT * FROM t2;
......@@ -131,7 +110,6 @@ c1 c2
203 d
COMMIT;
connection con2;
'T3'
SET AUTOCOMMIT=0;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
BEGIN;
......@@ -148,7 +126,6 @@ c1 c2
202 c
203 d
connection con1;
'T1'
UPDATE t1 SET c1 = c1 + 100;
SELECT * FROM t1;
c1 c2
......@@ -158,44 +135,34 @@ c1 c2
203 3
COMMIT;
connection con2;
'T3'
SET DEBUG_SYNC='row_select_wait WAIT_FOR waiting1';
SELECT * FROM t1;;
connection con1;
'T2'
SET DEBUG_SYNC='now SIGNAL waiting1';
'Signalled T3'
connection con2;
'T3'
c1 c2
100 0
101 1
102 2
103 3
connection con2;
'T3'
SET DEBUG_SYNC='row_select_wait WAIT_FOR waiting1';
SELECT * FROM t2;;
connection default;
'T2'
SET DEBUG_SYNC='now SIGNAL waiting1';
'Signalled T3'
connection con2;
'T3'
c1 c2
200 a
201 b
202 c
203 d
connection default;
disconnect con1;
disconnect con2;
connection default;
DROP TABLE t1;
DROP TABLE t2;
#
# Bug 21433768: NON-REPEATABLE READ WITH REPEATABLE READ ISOLATION
#
connect con1,localhost,root,,;
connection con1;
CREATE TABLE t1(col1 INT PRIMARY KEY, col2 INT) ENGINE = InnoDB;
INSERT INTO t1 values (1, 0), (2, 0);
SELECT * FROM t1 ORDER BY col1;
......@@ -218,5 +185,5 @@ SET DEBUG_SYNC = 'now SIGNAL s2';
connection con1;
disconnect con1;
connection default;
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
SET @save_timeout=@@GLOBAL.innodb_lock_wait_timeout;
SET GLOBAL innodb_lock_wait_timeout=100000000;
DESCRIBE INFORMATION_SCHEMA.INNODB_TRX;
Field Type Null Key Default Extra
trx_id varchar(18) NO NULL
trx_state varchar(13) NO NULL
trx_started datetime NO NULL
trx_requested_lock_id varchar(81) YES NULL
trx_wait_started datetime YES NULL
trx_weight bigint(21) unsigned NO NULL
trx_mysql_thread_id bigint(21) unsigned NO NULL
trx_query varchar(1024) YES NULL
trx_operation_state varchar(64) YES NULL
trx_tables_in_use bigint(21) unsigned NO NULL
trx_tables_locked bigint(21) unsigned NO NULL
trx_lock_structs bigint(21) unsigned NO NULL
trx_lock_memory_bytes bigint(21) unsigned NO NULL
trx_rows_locked bigint(21) unsigned NO NULL
trx_rows_modified bigint(21) unsigned NO NULL
trx_concurrency_tickets bigint(21) unsigned NO NULL
trx_isolation_level varchar(16) NO NULL
trx_unique_checks int(1) NO NULL
trx_foreign_key_checks int(1) NO NULL
trx_last_foreign_key_error varchar(256) YES NULL
trx_is_read_only int(1) NO NULL
trx_autocommit_non_locking int(1) NO NULL
CREATE TABLE t1 (
c01 INT,
c02 INT,
PRIMARY KEY (c01)
) ENGINE=INNODB STATS_AUTO_RECALC=0;
INSERT INTO t1 VALUES
(1,2),(2,4),(3,6),(4,8);
CREATE TABLE t2 (
c01 INT,
c02 INT,
PRIMARY KEY (c01),
FOREIGN KEY fk1 (c02) REFERENCES t1 (c01)
) ENGINE=INNODB STATS_AUTO_RECALC=0;
INSERT INTO t2 VALUES
(1,1),(2,2),(3,3);
connect con_trx,localhost,root,,;
connect con_verify_innodb_trx,localhost,root,,;
connection con_trx;
SET autocommit=0;
INSERT INTO t1 VALUES (5,10);
SELECT * FROM t1 FOR UPDATE;
c01 c02
1 2
2 4
3 6
4 8
5 10
connection con_verify_innodb_trx;
SELECT trx_state, trx_weight, trx_tables_in_use, trx_tables_locked,
trx_rows_locked, trx_rows_modified, trx_concurrency_tickets,
trx_isolation_level, trx_unique_checks, trx_foreign_key_checks
FROM INFORMATION_SCHEMA.INNODB_TRX;
trx_state trx_weight trx_tables_in_use trx_tables_locked trx_rows_locked trx_rows_modified trx_concurrency_tickets trx_isolation_level trx_unique_checks trx_foreign_key_checks
RUNNING 3 0 1 6 1 0 REPEATABLE READ 1 1
connection con_trx;
ROLLBACK;
SET FOREIGN_KEY_CHECKS = 0;
SET UNIQUE_CHECKS = 0;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN;
INSERT INTO t1 VALUES (6,12);
connection con_verify_innodb_trx;
SELECT trx_isolation_level, trx_unique_checks, trx_foreign_key_checks
FROM INFORMATION_SCHEMA.INNODB_TRX;
trx_isolation_level trx_unique_checks trx_foreign_key_checks
SERIALIZABLE 0 0
connection con_trx;
ROLLBACK;
SET FOREIGN_KEY_CHECKS = 1;
SET UNIQUE_CHECKS = 1;
BEGIN;
INSERT INTO t2 VALUES (4,10);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk1` FOREIGN KEY (`c02`) REFERENCES `t1` (`c01`))
disconnect con_trx;
connection con_verify_innodb_trx;
SELECT trx_state, trx_isolation_level, trx_last_foreign_key_error
FROM INFORMATION_SCHEMA.INNODB_TRX;
trx_state trx_isolation_level trx_last_foreign_key_error
RUNNING REPEATABLE READ `test`.`t2`, CONSTRAINT `fk1` FOREIGN KEY (`c02`) REFERENCES `t1` (`c01`)
disconnect con_verify_innodb_trx;
connection default;
DROP TABLE t2;
DROP TABLE t1;
SET GLOBAL innodb_lock_wait_timeout=@save_timeout;
FOUND 1 /\[Warning\] InnoDB: innodb_open_files 1000000 should not be greater than the open_files_limit [0-9]+/ in mysqld.1.err
CREATE TABLE t1 ENGINE=InnoDB AS SELECT * FROM mysql.help_topic;
DROP TABLE t1;
CREATE TABLE autorecalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB;
SELECT n_rows, clustered_index_size FROM mysql.innodb_table_stats WHERE table_name = 'autorecalc';
n_rows 0
clustered_index_size 1
SELECT index_name, stat_name, stat_value FROM mysql.innodb_index_stats WHERE table_name = 'autorecalc';
index_name PRIMARY
stat_name n_diff_pfx01
stat_value 0
index_name PRIMARY
stat_name n_leaf_pages
stat_value 1
index_name PRIMARY
stat_name size
stat_value 1
INSERT INTO autorecalc VALUES (1);
INSERT INTO autorecalc VALUES (2);
SELECT n_rows, clustered_index_size FROM mysql.innodb_table_stats WHERE table_name = 'autorecalc';
n_rows 2
clustered_index_size 1
SELECT index_name, stat_name, stat_value FROM mysql.innodb_index_stats WHERE table_name = 'autorecalc';
index_name PRIMARY
stat_name n_diff_pfx01
stat_value 2
index_name PRIMARY
stat_name n_leaf_pages
stat_value 1
index_name PRIMARY
stat_name size
stat_value 1
DELETE FROM autorecalc;
SELECT n_rows, clustered_index_size FROM mysql.innodb_table_stats WHERE table_name = 'autorecalc';
n_rows 0
clustered_index_size 1
SELECT index_name, stat_name, stat_value FROM mysql.innodb_index_stats WHERE table_name = 'autorecalc';
index_name PRIMARY
stat_name n_diff_pfx01
stat_value 0
index_name PRIMARY
stat_name n_leaf_pages
stat_value 1
index_name PRIMARY
stat_name size
stat_value 1
DROP TABLE autorecalc;
CREATE TABLE arddl (a INT, b INT, PRIMARY KEY (a)) ENGINE=INNODB;
INSERT INTO arddl VALUES (1, 10);
INSERT INTO arddl VALUES (2, 10);
ALTER TABLE arddl ADD INDEX (b);
SELECT n_rows FROM mysql.innodb_table_stats WHERE table_name = 'arddl' ORDER BY 1;
n_rows 2
SELECT index_name, stat_name, stat_value FROM mysql.innodb_index_stats WHERE table_name = 'arddl' AND index_name = 'PRIMARY' ORDER BY 1, 2, 3;
index_name PRIMARY
stat_name n_diff_pfx01
stat_value 2
index_name PRIMARY
stat_name n_leaf_pages
stat_value 1
index_name PRIMARY
stat_name size
stat_value 1
DROP TABLE arddl;
CREATE TABLE arddl (a INT, b INT, PRIMARY KEY (a), KEY (b)) ENGINE=INNODB;
INSERT INTO arddl VALUES (3, 10);
INSERT INTO arddl VALUES (4, 10);
ALTER TABLE arddl DROP INDEX b;
SELECT n_rows FROM mysql.innodb_table_stats WHERE table_name = 'arddl' ORDER BY 1;
n_rows 2
SELECT index_name, stat_name, stat_value FROM mysql.innodb_index_stats WHERE table_name = 'arddl' AND index_name = 'PRIMARY' ORDER BY 1, 2, 3;
index_name PRIMARY
stat_name n_diff_pfx01
stat_value 2
index_name PRIMARY
stat_name n_leaf_pages
stat_value 1
index_name PRIMARY
stat_name size
stat_value 1
DROP TABLE arddl;
SELECT table_name, n_rows FROM mysql.innodb_table_stats WHERE table_name LIKE 'ar_%' ORDER BY table_name;
table_name n_rows
ar_1001 0
ar_1002 0
ar_1003 0
ar_1004 0
ar_1005 0
ar_1006 0
ar_1007 0
ar_1008 0
ar_1009 0
ar_1010 0
ar_1011 0
ar_1012 0
ar_1013 0
ar_1014 0
ar_1015 0
ar_1016 0
ar_1017 0
ar_1018 0
ar_1019 0
ar_1020 0
ar_1021 0
ar_1022 0
ar_1023 0
ar_1024 0
ar_1025 0
ar_1026 0
ar_1027 0
ar_1028 0
ar_1029 0
ar_1030 0
ar_1031 0
ar_1032 0
ar_1033 0
ar_1034 0
ar_1035 0
ar_1036 0
ar_1037 0
ar_1038 0
ar_1039 0
ar_1040 0
ar_1041 0
ar_1042 0
ar_1043 0
ar_1044 0
ar_1045 0
ar_1046 0
ar_1047 0
ar_1048 0
ar_1049 0
ar_1050 0
ar_1051 0
ar_1052 0
ar_1053 0
ar_1054 0
ar_1055 0
ar_1056 0
ar_1057 0
ar_1058 0
ar_1059 0
ar_1060 0
ar_1061 0
ar_1062 0
ar_1063 0
ar_1064 0
ar_1065 0
ar_1066 0
ar_1067 0
ar_1068 0
ar_1069 0
ar_1070 0
ar_1071 0
ar_1072 0
ar_1073 0
ar_1074 0
ar_1075 0
ar_1076 0
ar_1077 0
ar_1078 0
ar_1079 0
ar_1080 0
ar_1081 0
ar_1082 0
ar_1083 0
ar_1084 0
ar_1085 0
ar_1086 0
ar_1087 0
ar_1088 0
ar_1089 0
ar_1090 0
ar_1091 0
ar_1092 0
ar_1093 0
ar_1094 0
ar_1095 0
ar_1096 0
ar_1097 0
ar_1098 0
ar_1099 0
ar_1100 0
ar_1101 0
ar_1102 0
ar_1103 0
ar_1104 0
ar_1105 0
ar_1106 0
ar_1107 0
ar_1108 0
ar_1109 0
ar_1110 0
ar_1111 0
ar_1112 0
ar_1113 0
ar_1114 0
ar_1115 0
ar_1116 0
ar_1117 0
ar_1118 0
ar_1119 0
ar_1120 0
ar_1121 0
ar_1122 0
ar_1123 0
ar_1124 0
ar_1125 0
ar_1126 0
ar_1127 0
ar_1128 0
ar_1129 0
ar_1130 0
ar_1131 0
ar_1132 0
ar_1133 0
ar_1134 0
ar_1135 0
ar_1136 0
ar_1137 0
ar_1138 0
ar_1139 0
ar_1140 0
ar_1141 0
ar_1142 0
ar_1143 0
ar_1144 0
ar_1145 0
ar_1146 0
ar_1147 0
ar_1148 0
ar_1149 0
ar_1150 0
ar_1151 0
ar_1152 0
ar_1153 0
ar_1154 0
ar_1155 0
ar_1156 0
ar_1157 0
ar_1158 0
ar_1159 0
ar_1160 0
ar_1161 0
ar_1162 0
ar_1163 0
ar_1164 0
ar_1165 0
ar_1166 0
ar_1167 0
ar_1168 0
ar_1169 0
ar_1170 0
ar_1171 0
ar_1172 0
ar_1173 0
ar_1174 0
ar_1175 0
ar_1176 0
ar_1177 0
ar_1178 0
ar_1179 0
ar_1180 0
ar_1181 0
ar_1182 0
ar_1183 0
ar_1184 0
ar_1185 0
ar_1186 0
ar_1187 0
ar_1188 0
ar_1189 0
ar_1190 0
ar_1191 0
ar_1192 0
ar_1193 0
ar_1194 0
ar_1195 0
ar_1196 0
ar_1197 0
ar_1198 0
ar_1199 0
ar_1200 0
Test with default setting
CREATE TABLE t (a INT, PRIMARY KEY (a)) ENGINE=INNODB;
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
COUNT(*) 1
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
COUNT(*) 3
FLUSH TABLE t;
DELETE FROM mysql.innodb_index_stats WHERE table_name = 't';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 't';
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
COUNT(*) 0
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
COUNT(*) 0
SELECT * FROM t;
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
COUNT(*) 1
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
COUNT(*) 3
DROP TABLE t;
Test with explicit enable
CREATE TABLE t (a INT, PRIMARY KEY (a)) ENGINE=INNODB STATS_AUTO_RECALC=1;
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
COUNT(*) 1
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
COUNT(*) 3
FLUSH TABLE t;
DELETE FROM mysql.innodb_index_stats WHERE table_name = 't';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 't';
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
COUNT(*) 0
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
COUNT(*) 0
SELECT * FROM t;
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
COUNT(*) 1
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
COUNT(*) 3
DROP TABLE t;
Test with explicit disable
CREATE TABLE t (a INT, PRIMARY KEY (a)) ENGINE=INNODB STATS_AUTO_RECALC=0;
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
COUNT(*) 1
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
COUNT(*) 3
FLUSH TABLE t;
DELETE FROM mysql.innodb_index_stats WHERE table_name = 't';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 't';
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
COUNT(*) 0
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
COUNT(*) 0
SELECT * FROM t;
SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't';
COUNT(*) 0
SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't';
COUNT(*) 0
DROP TABLE t;
CREATE TABLE bug18384390 (
id INT AUTO_INCREMENT PRIMARY KEY,
txt VARCHAR(10000)
) ENGINE=INNODB STATS_PERSISTENT=1 STATS_AUTO_RECALC=0;
INSERT INTO bug18384390 (txt) SELECT REPEAT('0', 10000) FROM seq_1_to_1024;
set use_stat_tables=never;
ANALYZE TABLE bug18384390;
Table Op Msg_type Msg_text
test.bug18384390 analyze status OK
DROP TABLE bug18384390;
@@ -18,7 +18,7 @@
test.test_ps_flag analyze status OK
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_after
-1
+0
DROP TABLE test_ps_flag;
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=default;
SHOW CREATE TABLE test_ps_flag;
@@ -37,7 +37,7 @@
test.test_ps_flag analyze status OK
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_after
-1
+0
DROP TABLE test_ps_flag;
=====
=== Test ANALYZE behavior after creation with explicit PS=OFF
@@ -142,7 +142,7 @@
test.test_ps_flag analyze status OK
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_after
-1
+0
DROP TABLE test_ps_flag;
=====
=== Test ANALYZE behavior after creation with explicit PS=ON,
@@ -203,5 +203,5 @@
test.test_ps_flag analyze status OK
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_after
-1
+0
DROP TABLE test_ps_flag;
=====
=== Test ANALYZE behavior after default creation
=====
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB;
SHOW CREATE TABLE test_ps_flag;
Table Create Table
test_ps_flag CREATE TABLE `test_ps_flag` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_before
0
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE test_ps_flag;
Table Op Msg_type Msg_text
test.test_ps_flag analyze status OK
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_after
1
DROP TABLE test_ps_flag;
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=default;
SHOW CREATE TABLE test_ps_flag;
Table Create Table
test_ps_flag CREATE TABLE `test_ps_flag` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_before
0
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE test_ps_flag;
Table Op Msg_type Msg_text
test.test_ps_flag analyze status OK
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_after
1
DROP TABLE test_ps_flag;
=====
=== Test ANALYZE behavior after creation with explicit PS=OFF
=====
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=0;
SHOW CREATE TABLE test_ps_flag;
Table Create Table
test_ps_flag CREATE TABLE `test_ps_flag` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_PERSISTENT=0
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_before
0
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE test_ps_flag;
Table Op Msg_type Msg_text
test.test_ps_flag analyze status OK
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_after
0
DROP TABLE test_ps_flag;
=====
=== Test ANALYZE behavior after creation with explicit PS=ON
=====
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=1;
SHOW CREATE TABLE test_ps_flag;
Table Create Table
test_ps_flag CREATE TABLE `test_ps_flag` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_PERSISTENT=1
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_before
0
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE test_ps_flag;
Table Op Msg_type Msg_text
test.test_ps_flag analyze status OK
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_after
1
DROP TABLE test_ps_flag;
=====
=== Test ANALYZE behavior after creation with explicit PS=OFF,
=== then ALTER to ON, then ALTER to OFF, then ALTER to default
=====
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=0;
ALTER TABLE test_ps_flag STATS_PERSISTENT=1;
# restart
SHOW CREATE TABLE test_ps_flag;
Table Create Table
test_ps_flag CREATE TABLE `test_ps_flag` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_PERSISTENT=1
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_before
0
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE test_ps_flag;
Table Op Msg_type Msg_text
test.test_ps_flag analyze status OK
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_after
1
ALTER TABLE test_ps_flag STATS_PERSISTENT=0;
SHOW CREATE TABLE test_ps_flag;
Table Create Table
test_ps_flag CREATE TABLE `test_ps_flag` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_PERSISTENT=0
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_before
0
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE test_ps_flag;
Table Op Msg_type Msg_text
test.test_ps_flag analyze status OK
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_after
0
ALTER TABLE test_ps_flag STATS_PERSISTENT=default;
SHOW CREATE TABLE test_ps_flag;
Table Create Table
test_ps_flag CREATE TABLE `test_ps_flag` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_before
0
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE test_ps_flag;
Table Op Msg_type Msg_text
test.test_ps_flag analyze status OK
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_after
1
DROP TABLE test_ps_flag;
=====
=== Test ANALYZE behavior after creation with explicit PS=ON,
=== then ALTER to OFF, then ALTER to ON, then ALTER to default
=====
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=1;
ALTER TABLE test_ps_flag STATS_PERSISTENT=0;
# restart
SHOW CREATE TABLE test_ps_flag;
Table Create Table
test_ps_flag CREATE TABLE `test_ps_flag` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_PERSISTENT=0
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_before
0
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE test_ps_flag;
Table Op Msg_type Msg_text
test.test_ps_flag analyze status OK
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_after
0
ALTER TABLE test_ps_flag STATS_PERSISTENT=1;
SHOW CREATE TABLE test_ps_flag;
Table Create Table
test_ps_flag CREATE TABLE `test_ps_flag` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_PERSISTENT=1
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_before
0
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE test_ps_flag;
Table Op Msg_type Msg_text
test.test_ps_flag analyze status OK
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_after
1
ALTER TABLE test_ps_flag STATS_PERSISTENT=default;
SHOW CREATE TABLE test_ps_flag;
Table Create Table
test_ps_flag CREATE TABLE `test_ps_flag` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_before
0
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE test_ps_flag;
Table Op Msg_type Msg_text
test.test_ps_flag analyze status OK
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
cnt_after
1
DROP TABLE test_ps_flag;
......@@ -10,9 +10,9 @@ CREATE TABLE t1 (id SERIAL, val INT UNSIGNED NOT NULL, KEY(val))
ENGINE=INNODB STATS_PERSISTENT=1,STATS_AUTO_RECALC=1;
CREATE TABLE t2 LIKE t1;
INSERT INTO t1 (val) SELECT 4 FROM seq_1_to_16;
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
connect con1, localhost, root,,;
START TRANSACTION;
......@@ -91,7 +91,7 @@ COUNT(*)
# ha_innobase::records_in_range() would count the delete-marked records.
EXPLAIN SELECT * FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL val 4 NULL 16 Using index
1 SIMPLE t1 index NULL val 4 NULL 1 Using index
ROLLBACK;
EXPLAIN SELECT * FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
......@@ -106,3 +106,25 @@ SET GLOBAL innodb_stats_include_delete_marked = @saved_include_delete_marked;
SET GLOBAL innodb_stats_traditional = @saved_traditional;
SET GLOBAL innodb_stats_modified_counter = @saved_modified_counter;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
CREATE TABLE bug12429573 (i INTEGER PRIMARY KEY, j INTEGER, KEY(j))
ENGINE=INNODB STATS_PERSISTENT=1;
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE bug12429573;
Table Op Msg_type Msg_text
test.bug12429573 analyze status OK
SELECT last_update INTO @last FROM mysql.innodb_table_stats
WHERE table_name = 'bug12429573';
SELECT * FROM mysql.innodb_index_stats
WHERE table_name = 'bug12429573' AND last_update!=@last;
database_name table_name index_name last_update stat_name stat_value sample_size stat_description
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE bug12429573;
Table Op Msg_type Msg_text
test.bug12429573 analyze status OK
SELECT * FROM mysql.innodb_table_stats
WHERE table_name = 'bug12429573' AND last_update=@last;
database_name table_name last_update n_rows clustered_index_size sum_of_other_index_sizes
SELECT * FROM mysql.innodb_index_stats
WHERE table_name = 'bug12429573' AND last_update=@last;
database_name table_name index_name last_update stat_name stat_value sample_size stat_description
DROP TABLE bug12429573;
SET GLOBAL innodb_stats_persistent_sample_pages=17;
CREATE TABLE test_ps_sample_pages_used (
a VARCHAR(512), PRIMARY KEY (a)
) ENGINE=INNODB STATS_SAMPLE_PAGES=default;
BEGIN;
COMMIT;
ANALYZE TABLE test_ps_sample_pages_used;
Table Op Msg_type Msg_text
test.test_ps_sample_pages_used analyze status Engine-independent statistics collected
test.test_ps_sample_pages_used analyze status OK
SELECT stat_name, stat_value FROM mysql.innodb_index_stats
WHERE table_name='test_ps_sample_pages_used' AND stat_name='n_leaf_pages';
stat_name stat_value
n_leaf_pages 37
SELECT sample_size FROM mysql.innodb_index_stats
WHERE table_name='test_ps_sample_pages_used' AND stat_name='n_diff_pfx01';
sample_size
17
ALTER TABLE test_ps_sample_pages_used STATS_SAMPLE_PAGES=14;
ANALYZE TABLE test_ps_sample_pages_used;
Table Op Msg_type Msg_text
test.test_ps_sample_pages_used analyze status Engine-independent statistics collected
test.test_ps_sample_pages_used analyze status OK
SELECT sample_size FROM mysql.innodb_index_stats
WHERE table_name='test_ps_sample_pages_used' AND stat_name='n_diff_pfx01';
sample_size
14
DROP TABLE test_ps_sample_pages_used;
SET GLOBAL innodb_stats_persistent_sample_pages=default;
CREATE TABLE test_ps_auto_recalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB;
SHOW CREATE TABLE test_ps_auto_recalc;
Table test_ps_auto_recalc
Create Table CREATE TABLE `test_ps_auto_recalc` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_auto_recalc';
create_options
ALTER TABLE test_ps_auto_recalc STATS_AUTO_RECALC=1;
# restart
SHOW CREATE TABLE test_ps_auto_recalc;
Table test_ps_auto_recalc
Create Table CREATE TABLE `test_ps_auto_recalc` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_AUTO_RECALC=1
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_auto_recalc';
create_options stats_auto_recalc=1
DROP TABLE test_ps_auto_recalc;
CREATE TABLE test_ps_auto_recalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_AUTO_RECALC=default;
SHOW CREATE TABLE test_ps_auto_recalc;
Table test_ps_auto_recalc
Create Table CREATE TABLE `test_ps_auto_recalc` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_auto_recalc';
create_options
DROP TABLE test_ps_auto_recalc;
CREATE TABLE test_ps_auto_recalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_AUTO_RECALC=0;
# restart
SHOW CREATE TABLE test_ps_auto_recalc;
Table test_ps_auto_recalc
Create Table CREATE TABLE `test_ps_auto_recalc` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_AUTO_RECALC=0
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_auto_recalc';
create_options stats_auto_recalc=0
ALTER TABLE test_ps_auto_recalc STATS_AUTO_RECALC=1;
# restart
SHOW CREATE TABLE test_ps_auto_recalc;
Table test_ps_auto_recalc
Create Table CREATE TABLE `test_ps_auto_recalc` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_AUTO_RECALC=1
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_auto_recalc';
create_options stats_auto_recalc=1
DROP TABLE test_ps_auto_recalc;
CREATE TABLE test_ps_auto_recalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_AUTO_RECALC=1;
# restart
SHOW CREATE TABLE test_ps_auto_recalc;
Table test_ps_auto_recalc
Create Table CREATE TABLE `test_ps_auto_recalc` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_AUTO_RECALC=1
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_auto_recalc';
create_options stats_auto_recalc=1
ALTER TABLE test_ps_auto_recalc STATS_AUTO_RECALC=0;
# restart
SHOW CREATE TABLE test_ps_auto_recalc;
Table test_ps_auto_recalc
Create Table CREATE TABLE `test_ps_auto_recalc` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_AUTO_RECALC=0
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_auto_recalc';
create_options stats_auto_recalc=0
DROP TABLE test_ps_auto_recalc;
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB;
SHOW CREATE TABLE test_ps_sample_pages;
Table test_ps_sample_pages
Create Table CREATE TABLE `test_ps_sample_pages` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_sample_pages';
create_options
ALTER TABLE test_ps_sample_pages STATS_SAMPLE_PAGES=12345;
# restart
SHOW CREATE TABLE test_ps_sample_pages;
Table test_ps_sample_pages
Create Table CREATE TABLE `test_ps_sample_pages` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_SAMPLE_PAGES=12345
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_sample_pages';
create_options stats_sample_pages=12345
DROP TABLE test_ps_sample_pages;
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=default;
SHOW CREATE TABLE test_ps_sample_pages;
Table test_ps_sample_pages
Create Table CREATE TABLE `test_ps_sample_pages` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_sample_pages';
create_options
DROP TABLE test_ps_sample_pages;
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=-5;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-5' at line 2
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=0;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '0' at line 2
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=67000;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '67000' at line 2
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=670000;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '670000' at line 2
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=65536;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '65536' at line 2
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=65535;
SHOW CREATE TABLE test_ps_sample_pages;
Table test_ps_sample_pages
Create Table CREATE TABLE `test_ps_sample_pages` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_SAMPLE_PAGES=65535
DROP TABLE test_ps_sample_pages;
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=1;
# restart
SHOW CREATE TABLE test_ps_sample_pages;
Table test_ps_sample_pages
Create Table CREATE TABLE `test_ps_sample_pages` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_SAMPLE_PAGES=1
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_sample_pages';
create_options stats_sample_pages=1
DROP TABLE test_ps_sample_pages;
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=5678;
# restart
SHOW CREATE TABLE test_ps_sample_pages;
Table test_ps_sample_pages
Create Table CREATE TABLE `test_ps_sample_pages` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_SAMPLE_PAGES=5678
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_sample_pages';
create_options stats_sample_pages=5678
ALTER TABLE test_ps_sample_pages STATS_SAMPLE_PAGES=default;
# restart
SHOW CREATE TABLE test_ps_sample_pages;
Table test_ps_sample_pages
Create Table CREATE TABLE `test_ps_sample_pages` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_sample_pages';
create_options
DROP TABLE test_ps_sample_pages;
CREATE TABLE t (c INT) ENGINE=INNODB;
SET @save_dbug = @@debug_dbug;
SET debug_dbug = '+d,test_ut_format_name';
DROP TABLE t;
SET debug_dbug = @save_dbug;
@@ -39,7 +39,7 @@
WHERE
table_name='records_in_range_test' AND stat_name = 'size';
index_name stat_name stat_value
-PRIMARY size 1
+PRIMARY size 5
SET @save_dbug = @@debug_dbug;
SET DEBUG_DBUG='+d,print_btr_estimate_n_rows_in_range_return_value';
@@ -39,7 +39,7 @@
WHERE
table_name='records_in_range_test' AND stat_name = 'size';
index_name stat_name stat_value
-PRIMARY size 1
+PRIMARY size 3
SET @save_dbug = @@debug_dbug;
SET DEBUG_DBUG='+d,print_btr_estimate_n_rows_in_range_return_value';
This diff is collapsed.
#
# Test the limits of a file-per-table tablespace name. MySQL combines
# the database name with the table name to make a unique table name.
#
SET default_storage_engine=InnoDB;
#
# MySQL limits each database and tablename identifier to 64 characters
# of up to 3 bytes per character, corresponding to 192 bytes.
#
CREATE DATABASE `this_sixty_five_byte_name_is_too_long____________________________`;
ERROR 42000: Incorrect database name 'this_sixty_five_byte_name_is_too_long____________________________'
CREATE DATABASE `this_sixty_four_byte_name_is_not_too_long_______________________`;
USE `this_sixty_four_byte_name_is_not_too_long_______________________`;
#
# A 64 character tablename can be created in a 64 character database name
#
CREATE TABLE `this_sixty_four_byte_name_is_not_too_long_______________________`.`this_sixty_four_byte_name_is_not_too_long_______________________` (a SERIAL);
#
# A 65 character tablename is too long.
#
CREATE TABLE `test`.`this_sixty_five_byte_name_is_too_long____________________________` (a SERIAL);
ERROR 42000: Incorrect table name 'this_sixty_five_byte_name_is_too_long____________________________'
CREATE TABLE `this_sixty_four_byte_name_is_not_too_long_______________________`.`this_sixty_five_byte_name_is_too_long____________________________` (a SERIAL);
ERROR 42000: Incorrect table name 'this_sixty_five_byte_name_is_too_long____________________________'
#
# Non-non-filename-safe characters like '#' are expanded to '@0023'.
# On many file systems, such as Linux extfs, you can create a database name
# that expands to up to 255 bytes long.
# `##################################################_long` is expanded to
# (50 * 5) + 5 = 255.
#
CREATE DATABASE `##################################################_long`;;
USE `##################################################_long`;
#
# This 256-byte name is only one byte longer but fails with an error code
# from the stat operation.
# `##################################################_long_` is expanded to
# (50 * 5) + 6 = 256.
#
CREATE DATABASE `##################################################_long_`;
ERROR HY000: Can't get stat of './##################################################_long_' (Errcode: ## "File name too long")
#
# This 300-byte name which is the longest name that gets an error code
# from the stat operation.
# `###########################################################_long` is expanded to
# (59 * 5) + 5 = 300.
#
CREATE DATABASE `###########################################################_long`;
ERROR HY000: Can't get stat of './###########################################################_long' (Errcode: ## "File name too long")
#
# This 301-byte name which is only one byte longer but fails with ER_TOO_LONG_IDENT.
# `###########################################################_long_` is expanded to
# (59 * 5) + 6 = 301.
#
CREATE DATABASE `###########################################################_long_`;
ERROR 42000: Incorrect database name '###########################################################_long_'
USE test;
#
# An expanded table name is limited to 251 bytes
#
CREATE TABLE `test`.`#################################################_long_` (a SERIAL);
#
# A 252-byte tablename is too long
#
CREATE TABLE `test`.`#################################################_long___` (a SERIAL);
ERROR HY000: Can't create table `test`.`#################################################_long___` (errno: ## "File name too long")
CREATE DATABASE twenty_byte_db_name_;
USE `twenty_byte_db_name_`;
#
# A 251 byte expanded table name will fit with a longer database name
#
CREATE TABLE `twenty_byte_db_name_`.`#################################################_long_` (a SERIAL);
#
# A 252 byte expanded table name is also too long in a longer database name
#
CREATE TABLE `twenty_byte_db_name_`.`#################################################_long___` (a SERIAL);
ERROR HY000: Can't create table `twenty_byte_db_name_`.`#################################################_long___` (errno: ## "File name too long")
#
# Another limitation is a 512 byte length to an expanded path that includes
# the datadir which is './' in this test, the expanded database name,
# the directory separator '/', the expanded table name, and the file extension.
# './long_db_name.long_250_byte_table_name.frm'
# 2+ 255 +1+ 250 +1+3 = 512
#
CREATE TABLE `##################################################_long`.`#################################################_long` (a SERIAL);
CREATE TABLE `##################################################_long`.`#################################################_long_` (a SERIAL);
ERROR HY000: Long database name and identifier for object resulted in path length exceeding 512 characters. Path: './@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023_long/@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@
SHOW WARNINGS;
Level Code Message
Error 1860 Long database name and identifier for object resulted in path length exceeding 512 characters. Path: './@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023_long/@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@0023@
#
# Show the successfully created databases and tables
#
---- list_files MYSQLD_DATADIR/test
#################################################_long_.frm
#################################################_long_.ibd
db.opt
---- list_files MYSQLD_DATADIR/this_sixty_four_byte_name_is_not_too_long_______________________
db.opt
this_sixty_four_byte_name_is_not_too_long_______________________.frm
this_sixty_four_byte_name_is_not_too_long_______________________.ibd
---- list_files MYSQLD_DATADIR/##################################################_long
#################################################_long.frm
#################################################_long.ibd
db.opt
SELECT name FROM information_schema.innodb_sys_tables WHERE name LIKE '%long%';
name
##################################################_long/#################################################_long
test/#################################################_long_
this_sixty_four_byte_name_is_not_too_long_______________________/this_sixty_four_byte_name_is_not_too_long_______________________
twenty_byte_db_name_/#################################################_long_
SELECT name FROM information_schema.innodb_sys_tablespaces WHERE name LIKE '%long%';
name
this_sixty_four_byte_name_is_not_too_long_______________________/this_sixty_four_byte_name_is_not_too_long_______________________
test/#################################################_long_
twenty_byte_db_name_/#################################################_long_
##################################################_long/#################################################_long
SELECT path FROM information_schema.innodb_sys_datafiles WHERE path LIKE '%long%';
path
./this_sixty_four_byte_name_is_not_too_long_______________________/this_sixty_four_byte_name_is_not_too_long_______________________.ibd
./test/#################################################_long_.ibd
./twenty_byte_db_name_/#################################################_long_.ibd
./##################################################_long/#################################################_long.ibd
SELECT file_name, tablespace_name FROM information_schema.files WHERE file_name LIKE '%long%';
#
# Cleanup
#
DROP TABLE `this_sixty_four_byte_name_is_not_too_long_______________________`.`this_sixty_four_byte_name_is_not_too_long_______________________`;
DROP TABLE `test`.`#################################################_long_`;
DROP TABLE `twenty_byte_db_name_`.`#################################################_long_`;
DROP TABLE `##################################################_long`.`#################################################_long`;
DROP DATABASE `this_sixty_four_byte_name_is_not_too_long_______________________`;
DROP DATABASE `##################################################_long`;
DROP DATABASE `twenty_byte_db_name_`;
#
# Test the limits of a file-per-table tablespace name. MySQL combines
# the database name with the table name to make a unique table name.
#
SET default_storage_engine=InnoDB;
#
# MySQL limits each database and tablename identifier to 64 characters
# of up to 3 bytes per character, corresponding to 192 bytes.
#
CREATE DATABASE `this_sixty_five_byte_name_is_too_long____________________________`;
ERROR 42000: Incorrect database name 'this_sixty_five_byte_name_is_too_long____________________________'
CREATE DATABASE `this_sixty_four_byte_name_is_not_too_long_______________________`;
USE `this_sixty_four_byte_name_is_not_too_long_______________________`;
#
# A 64 character tablename can be created in a 64 character database name
#
CREATE TABLE `this_sixty_four_byte_name_is_not_too_long_______________________`.`this_sixty_four_byte_name_is_not_too_long_______________________` (a SERIAL);
#
# A 65 character tablename is too long.
#
CREATE TABLE `test`.`this_sixty_five_byte_name_is_too_long____________________________` (a SERIAL);
ERROR 42000: Incorrect table name 'this_sixty_five_byte_name_is_too_long____________________________'
CREATE TABLE `this_sixty_four_byte_name_is_not_too_long_______________________`.`this_sixty_five_byte_name_is_too_long____________________________` (a SERIAL);
ERROR 42000: Incorrect table name 'this_sixty_five_byte_name_is_too_long____________________________'
#
# Show the successfully created database and table
#
SHOW CREATE TABLE `this_sixty_four_byte_name_is_not_too_long_______________________`.`this_sixty_four_byte_name_is_not_too_long_______________________`;
Table Create Table
this_sixty_four_byte_name_is_not_too_long_______________________ CREATE TABLE `this_sixty_four_byte_name_is_not_too_long_______________________` (
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
UNIQUE KEY `a` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
---- list_files MYSQLD_DATADIR/this_sixty_four_byte_name_is_not_too_long_______________________
db.opt
this_sixty_four_byte_name_is_not_too_long_______________________.frm
this_sixty_four_byte_name_is_not_too_long_______________________.ibd
SELECT name FROM information_schema.innodb_sys_tables WHERE name LIKE '%long%';
name
this_sixty_four_byte_name_is_not_too_long_______________________/this_sixty_four_byte_name_is_not_too_long_______________________
SELECT name FROM information_schema.innodb_sys_tablespaces WHERE name LIKE '%long%';
name
this_sixty_four_byte_name_is_not_too_long_______________________/this_sixty_four_byte_name_is_not_too_long_______________________
SELECT path FROM information_schema.innodb_sys_datafiles WHERE path LIKE '%long%';
path
.\this_sixty_four_byte_name_is_not_too_long_______________________\this_sixty_four_byte_name_is_not_too_long_______________________.ibd
SELECT file_name, tablespace_name FROM information_schema.files WHERE file_name LIKE '%long%';
#
# Cleanup
#
DROP DATABASE `this_sixty_four_byte_name_is_not_too_long_______________________`;
--source include/have_innodb.inc
--echo #
--echo # Bug #19471516 SERVER CRASHES WHEN EXECUTING ALTER TABLE ADD
--echo # FOREIGN KEY
--echo #
CREATE TABLE `parent` (`parent_id` INT, PRIMARY KEY (`parent_id`));
CREATE TABLE `child1` (`id` INT ,`child1_fk1` INT, `child1_fk2` INT,
PRIMARY KEY (`id`));
CREATE TABLE `child2` (`id` INT, `child2_fk1` INT, `child2_fk2` INT,
PRIMARY KEY (`id`));
CREATE TABLE `child3` (`id` INT , `child3_fk1` INT, PRIMARY KEY (`id`));
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk1`) REFERENCES `parent`
(`parent_id`);
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk1`) REFERENCES
`parent` (`parent_id`);
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk2`) REFERENCES `parent`
(`parent_id`);
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk1`) REFERENCES `parent`
(`parent_id`);
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk2`) REFERENCES `parent`
(`parent_id`);
ALTER TABLE `child3` ADD FOREIGN KEY (`child3_fk1`) REFERENCES `parent`
(`parent_id`);
ALTER TABLE `child1` ADD FOREIGN KEY (`child1_fk2`) REFERENCES
`parent` (`parent_id`);
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk1`) REFERENCES
`parent` (`parent_id`);
ALTER TABLE `child2` ADD FOREIGN KEY (`child2_fk2`) REFERENCES
`parent` (`parent_id`);
ALTER TABLE `child3` ADD FOREIGN KEY (`child3_fk1`) REFERENCES
`parent` (`parent_id`);
drop table child3, child2, child1, parent;
--source include/have_innodb.inc
--source include/have_debug.inc
create table t1 (f1 int primary key) engine=innodb;
create table t2 (f1 int primary key,
constraint c1 foreign key (f1) references t1(f1)
on update cascade
on delete cascade) engine=innodb;
create table t3 (f1 int primary key,
constraint c2 foreign key (f1) references t1(f1)
on update cascade
on delete cascade) engine=innodb;
show create table t1;
show create table t2;
show create table t3;
insert into t1 values (1);
insert into t1 values (2);
insert into t1 values (3);
insert into t2 values (1);
insert into t2 values (2);
insert into t2 values (3);
insert into t3 values (1);
insert into t3 values (2);
insert into t3 values (3);
select f1 from t1;
select f1 from t2;
select f1 from t3;
set @save_dbug = @@debug_dbug;
set debug_dbug = '+d,dml_cascade_only_once';
set debug_dbug = '+d,row_upd_cascade_lock_wait_err';
update t1 set f1 = 100 where f1 = 2;
select f1 from t1;
select f1 from t2;
select f1 from t3;
set debug_dbug = @save_dbug;
drop table t2;
drop table t3;
drop table t1;
#
# BUG#20125349 - PERSISTANT STATS IS NOT UPDATED WHEN TTS IS IMPORTED.
#
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/not_valgrind.inc # MDEV-32725 FIXME
let MYSQLD_DATADIR =`SELECT @@datadir`;
SET @old_innodb_file_per_table = @@innodb_file_per_table;
SET GLOBAL innodb_file_per_table = 1;
SELECT @@innodb_file_per_table;
CREATE TABLE t1 (
col_1 CHAR (255),
col_2 VARCHAR (255)
) ENGINE = InnoDB;
CREATE INDEX idx1 ON t1(col_1);
CREATE INDEX idx2 ON t1(col_2);
SHOW INDEXES FROM t1;
INSERT INTO t1 VALUES ("col1_00001", "col2_00001"), ("col1_00002", "col2_00002");
SHOW INDEXES FROM t1;
ANALYZE TABLE t1;
SHOW INDEXES FROM t1;
FLUSH TABLES t1 FOR EXPORT;
perl;
do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl";
ib_backup_tablespaces("test", "t1");
EOF
UNLOCK TABLES;
DROP TABLE t1;
CREATE TABLE t1 (
col_1 CHAR (255),
col_2 VARCHAR (255)
) ENGINE = InnoDB STATS_PERSISTENT=1;
CREATE INDEX idx1 ON t1(col_1);
CREATE INDEX idx2 ON t1(col_2);
SHOW INDEXES FROM t1;
INSERT INTO t1 VALUES ("col1_00001", "col2_00001");
SHOW INDEXES FROM t1;
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE t1;
SHOW INDEXES FROM t1;
ALTER TABLE t1 DISCARD TABLESPACE;
perl;
do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
ALTER TABLE t1 IMPORT TABLESPACE;
SHOW INDEXES FROM t1;
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE t1;
SHOW INDEXES FROM t1;
DROP TABLE t1;
SET GLOBAL innodb_file_per_table = @old_innodb_file_per_table;
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp t1*.ibd
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp t1*.cfg
--source include/have_innodb.inc
--connect (stop_purge,localhost,root)
# Prevent the purge of history from acquiring a table handle.
START TRANSACTION WITH CONSISTENT SNAPSHOT;
--connection default
CREATE TABLE t1(a INT PRIMARY KEY, b VARCHAR(1024))
ENGINE=InnoDB STATS_PERSISTENT=1;
INSERT INTO t1 VALUES (1,REPEAT('b',1024));
SELECT index_length FROM information_schema.tables
WHERE table_schema = 'test' AND table_name = 't1';
ALTER TABLE t1 ADD INDEX b (b(800));
SELECT FLOOR(index_length/@@innodb_page_size) FROM information_schema.tables
WHERE table_schema = 'test' AND table_name = 't1';
ALTER TABLE t1 ADD INDEX ba (b(800),a);
SELECT FLOOR(index_length/@@innodb_page_size) FROM information_schema.tables
WHERE table_schema = 'test' AND table_name = 't1';
disconnect stop_purge;
DROP TABLE t1;
--echo # End of 10.4 tests
......@@ -7,6 +7,19 @@ call mtr.add_suppression("Innodb: Cannot add field.*row size is");
let $MYSQLD_DATADIR= `select @@datadir`;
SET SESSION innodb_strict_mode=ON;
--error ER_CANT_CREATE_TABLE
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
--error ER_CANT_CREATE_TABLE
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB KEY_BLOCK_SIZE=4;
SET SESSION innodb_strict_mode=OFF;
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
SHOW WARNINGS;
DROP TABLE t1;
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB KEY_BLOCK_SIZE=4;
SHOW WARNINGS;
DROP TABLE t1;
--echo # Test 1) Show the page size from Information Schema
SELECT variable_value FROM information_schema.global_status
WHERE LOWER(variable_name) = 'innodb_page_size';
......
......@@ -8,6 +8,19 @@ call mtr.add_suppression('InnoDB: Cannot add field.*because after adding it, the
let $MYSQLD_DATADIR= `select @@datadir`;
SET SESSION innodb_strict_mode=ON;
--error ER_CANT_CREATE_TABLE
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
--error ER_CANT_CREATE_TABLE
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB KEY_BLOCK_SIZE=4;
SET SESSION innodb_strict_mode=OFF;
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
SHOW WARNINGS;
DROP TABLE t1;
CREATE TABLE t1(a int PRIMARY KEY) ENGINE=InnoDB KEY_BLOCK_SIZE=4;
SHOW WARNINGS;
DROP TABLE t1;
--echo # Test 1) Show the page size from Information Schema
SELECT variable_value FROM information_schema.global_status
WHERE LOWER(variable_name) = 'innodb_page_size';
......
# DEBUG_SYNC must be compiled in.
--source include/have_debug_sync.inc
--source include/have_debug.inc
--source include/have_innodb.inc
CREATE TABLE t1 (c1 INT , c2 CHAR(10), PRIMARY KEY (c1)) ENGINE = InnoDB;
INSERT INTO t1 VALUES(0, "0");
INSERT INTO t1 VALUES(1, "1");
INSERT INTO t1 VALUES(2, "2");
INSERT INTO t1 VALUES(3, "3");
--connect (con1,localhost,root,,)
--connect (con2,localhost,root,,)
--connect (con3,localhost,root,,)
--connect (con4,localhost,root,,)
--connect (con5,localhost,root,,)
--connect (con6,localhost,root,,)
connection default;
# Disable query log to avoid non-deterministic output conflicts
SET AUTOCOMMIT=0;
BEGIN;
# Lock all the records
SELECT * FROM t1 FOR UPDATE;
--disable_query_log
connection con1;
SET AUTOCOMMIT=1;
# Test if locking autocommit selects end up in the trx_sys_t::trx_list.
# We check this via the INFORMATION_SCHEMA.INNODB_TRX.
# This should block and show up in the I_S.
SET DEBUG_SYNC='lock_wait_suspend_thread_enter SIGNAL waiting1';
--send
SELECT COUNT(*) FROM t1 LOCK IN SHARE MODE;
connection con2;
SET AUTOCOMMIT=1;
# Test if non-locking autocommit selects end up in the trx_sys_t::trx_list.
# We check this via the INFORMATION_SCHEMA.INNODB_TRX.
# This should not block and should not show up in the I_S.
--send
SELECT COUNT(*) FROM t1;
connection con3;
SET AUTOCOMMIT=1;
# Note: autocommit non-locking selects are not converted to locking selects
# Therefore this should not block;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
--send
SELECT COUNT(*) FROM t1;
connection con4;
SET AUTOCOMMIT=0;
# Note: Non-locking selects are converted to locking selects
# therefore this should block;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SET DEBUG_SYNC='now WAIT_FOR waiting1';
SET DEBUG_SYNC='lock_wait_suspend_thread_enter SIGNAL waiting4';
--send
SELECT COUNT(*) FROM t1 WHERE c1 >= 0;
connection con5;
SET AUTOCOMMIT=1;
# This should not block
BEGIN;
--send
SELECT COUNT(*) FROM t1;
connection con6;
SET AUTOCOMMIT=1;
# This will ignore the auto-commit setting but wont block because it is
# a non-locking select.
XA START '1';
--enable_query_log
SELECT * FROM t1 WHERE c1 <= 3;
connection default;
# Wait for SELECTs to get into the lock wait queue
SET DEBUG_SYNC='now WAIT_FOR waiting4';
SET DEBUG_SYNC= 'RESET';
# Check the number of non-locking transactions
let $wait_condition =
SELECT COUNT(*) = 5
FROM INFORMATION_SCHEMA.INNODB_TRX
WHERE trx_autocommit_non_locking = 0;
--source include/wait_condition.inc
# Check the waiting transactions
SELECT trx_state, trx_query, trx_autocommit_non_locking
FROM INFORMATION_SCHEMA.INNODB_TRX
WHERE trx_state = 'LOCK WAIT'
ORDER BY trx_query;
INSERT INTO t1 VALUES(4, '4');
COMMIT;
connection con6;
SELECT * FROM t1 WHERE c1 <= 4;
XA END '1';
XA PREPARE '1';
XA ROLLBACK '1';
disconnect con6;
disconnect con2;
disconnect con3;
disconnect con5;
connection con1;
reap;
disconnect con1;
connection con4;
reap;
disconnect con4;
connection default;
DROP TABLE t1;
......@@ -690,6 +690,32 @@ ALTER TABLE t1 ADD COLUMN b DATETIME NOT NULL, LOCK=NONE;
SET @@SQL_MODE= @OLD_SQL_MODE;
DROP TABLE t1;
--echo #
--echo # Bug#20977779 CANNOT IMPORT TABLES CONTAINING PREFIX INDEXES
--echo #
CREATE TABLE t1 (c1 VARCHAR(32), c2 VARCHAR(32), c3 VARCHAR(32),
PRIMARY KEY (c1, c2, c3))
ENGINE=InnoDB;
ALTER TABLE t1 ADD INDEX ind1(c1(5), c2, c3);
ALTER TABLE t1 ADD INDEX ind2(c3, c1(10), c2);
ALTER TABLE t1 ADD INDEX ind3(c2, c3, c1(20));
INSERT INTO t1 VALUES ('Test Data -1', 'Test Data -2', 'Test Data -3');
let $source_db = test;
let $dest_db = test;
--echo # Test with 2ndary index having prefix
--source suite/innodb/include/import.inc
--echo # Test with PK & 2ndary index with prefix
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(c1(5), c2(10), c3(20));
--source suite/innodb/include/import.inc
DROP TABLE t1;
#
# End of 10.2 tests
#
......@@ -482,3 +482,32 @@ SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
DROP TABLE t2;
DROP TABLE t3;
--echo # Bug #17449901 TABLE DISAPPEARS WHEN ALTERING
--echo # WITH FOREIGN KEY CHECKS OFF
# Drop index via inplace algorithm
create table t1(f1 int,primary key(f1))engine=innodb;
create table t2(f2 int,f3 int,key t(f2,f3),foreign key(f2) references t1(f1))engine=innodb;
SET foreign_key_checks=0;
drop index t on t2;
drop table t2;
drop table t1;
# Drop index using alter statement via inplace
create table t1(f1 int ,primary key(f1))engine=innodb;
create table t2(f2 int,f3 int, key t(f2),foreign key(f2) references t1(f1))engine=innodb;
SET foreign_key_checks = 0;
alter table t2 drop key t,algorithm=inplace;
show create table t2;
drop table t2;
drop table t1;
create table t1(f1 int ,primary key(f1))engine=innodb;
create table t2(f2 int,f3 int, key t(f2),key t1(f2,f3),
foreign key(f2) references t1(f1))engine=innodb;
SET foreign_key_checks = 0;
alter table t2 drop key t,algorithm=inplace;
show create table t2;
drop table t2;
drop table t1;
--echo #
--echo # Bug #21025880 DUPLICATE UK VALUES IN READ-COMMITTED(AGAIN)
--echo #
--source include/have_innodb.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
SET @save_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
let $i=0;
while ($i <=1 )
{
CREATE TABLE t1 (
a INT NOT NULL,
b INT NOT NULL,
PRIMARY KEY(b),
UNIQUE KEY(a))
ENGINE=INNODB;
SET @old_innodb_stats_auto_recalc = @@innodb_stats_auto_recalc;
SET GLOBAL innodb_stats_auto_recalc = OFF;
# Block purge
connect purge_control,localhost,root;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connection default;
SET @old_tx_isolation = @@tx_isolation;
SET GLOBAL tx_isolation = 'READ-COMMITTED';
SET @old_innodb_lock_wait_timeout = @@innodb_lock_wait_timeout;
SET GLOBAL innodb_lock_wait_timeout = 1;
--connect(con1,localhost,root,,)
# Create and delete-mark an index record
INSERT INTO t1 VALUES (1,1),(2,2);
DELETE FROM t1;
SET debug_sync = 'row_ins_sec_index_entry_dup_locks_created SIGNAL
con1_locks_done WAIT_FOR con1_go';
SET debug_sync = 'ha_commit_trans_after_acquire_commit_lock SIGNAL
con1_insert_done WAIT_FOR con1_finish';
--send
if ($i == 0)
{
REPLACE INTO t1 VALUES (1,2);
}
if ( $i == 1)
{
INSERT INTO t1 values (1,2) ON DUPLICATE KEY UPDATE a=2;
}
--connect(con2,localhost,root,,)
SET debug_sync = 'now WAIT_FOR con1_locks_done';
SET debug_sync = 'lock_wait_suspend_thread_enter SIGNAL con2_blocked
WAIT_FOR con2_go';
SET debug_sync = 'ha_commit_trans_after_acquire_commit_lock
WAIT_FOR con2_finish';
SET debug_sync = 'ib_after_row_insert SIGNAL con2_insert_done';
--send
REPLACE INTO t1 VALUES (1,3);
--connection default
SET debug_sync = 'now WAIT_FOR con2_blocked';
connection purge_control;
COMMIT;
disconnect purge_control;
connection default;
# Wait for purge to delete the delete-marked record
--source ../../innodb/include/wait_all_purged.inc
SET debug_sync = 'now SIGNAL con2_go WAIT_FOR con2_insert_done';
SET debug_sync = 'now SIGNAL con1_go WAIT_FOR con1_insert_done';
SET debug_sync = 'now SIGNAL con1_finish';
--connection con1
--reap
--disconnect con1
--connection default
SET debug_sync = 'now SIGNAL con2_finish';
--connection con2
--error 0,ER_LOCK_WAIT_TIMEOUT
--reap
--disconnect con2
--connection default
SET DEBUG_SYNC= 'RESET';
SELECT * FROM t1;
CHECK TABLE t1;
DROP TABLE t1;
SET GLOBAL innodb_stats_auto_recalc = @old_innodb_stats_auto_recalc;
SET GLOBAL tx_isolation = @old_tx_isolation;
SET GLOBAL innodb_lock_wait_timeout = @old_innodb_lock_wait_timeout;
--inc $i
}
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
# DEBUG_SYNC must be compiled in.
--source include/have_debug_sync.inc
--source include/have_debug.inc
# We need to test the use case:
# a. Create a transaction T1 that will be promoted to RW.
# b. Create a transaction T2 that will be promoted to RW.
......@@ -27,22 +26,16 @@ INSERT INTO t2 VALUES(2, "c");
INSERT INTO t2 VALUES(3, "d");
--connect (con1,localhost,root,,)
--connect (con2,localhost,root,,)
connection con1;
--echo 'T1'
SET AUTOCOMMIT=0;
BEGIN;
SELECT * FROM t2;
connection default;
--echo 'T2'
SET AUTOCOMMIT=0;
BEGIN;
SELECT * FROM t1;
connection con2;
--echo 'T3'
--connect (con2,localhost,root,,)
SET AUTOCOMMIT=0;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
BEGIN;
......@@ -50,48 +43,36 @@ SELECT * FROM t1;
SELECT * FROM t2;
connection con1;
--echo 'T1'
UPDATE t2 SET c1 = c1 + 100;
SELECT * FROM t2;
COMMIT;
connection default;
--echo 'T2'
UPDATE t1 SET c1 = c1 + 100;
SELECT * FROM t1;
COMMIT;
connection con2;
--echo 'T3'
SET DEBUG_SYNC='row_search_for_mysql_before_return WAIT_FOR waiting1';
--send SELECT * FROM t1;
connection default;
--echo 'T2'
SET DEBUG_SYNC='now SIGNAL waiting1';
--echo 'Signalled T3'
connection con2;
--echo 'T3'
reap;
connection con2;
--echo 'T3'
SET DEBUG_SYNC='row_search_for_mysql_before_return WAIT_FOR waiting1';
--send SELECT * FROM t2;
connection default;
--echo 'T2'
SET DEBUG_SYNC='now SIGNAL waiting1';
--echo 'Signalled T3'
connection con2;
--echo 'T3'
reap;
connection default;
disconnect con1;
disconnect con2;
# We need to test the use case:
# a. Create a transaction T1 that will be promoted to RW.
......@@ -105,17 +86,12 @@ disconnect con2;
# i. T3 Does a select - it should not see the changes made by T1 but should
# see the changes by T2
--connect (con1,localhost,root,,)
--connect (con2,localhost,root,,)
connection con1;
--echo 'T1'
SET AUTOCOMMIT=0;
BEGIN;
SELECT * FROM t1;
connection default;
--echo 'T2'
SET AUTOCOMMIT=0;
BEGIN;
SELECT * FROM t2;
......@@ -124,7 +100,6 @@ SELECT * FROM t2;
COMMIT;
connection con2;
--echo 'T3'
SET AUTOCOMMIT=0;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
BEGIN;
......@@ -132,42 +107,30 @@ SELECT * FROM t1;
SELECT * FROM t2;
connection con1;
--echo 'T1'
UPDATE t1 SET c1 = c1 + 100;
SELECT * FROM t1;
COMMIT;
connection con2;
--echo 'T3'
SET DEBUG_SYNC='row_select_wait WAIT_FOR waiting1';
--send SELECT * FROM t1;
connection con1;
--echo 'T2'
SET DEBUG_SYNC='now SIGNAL waiting1';
--echo 'Signalled T3'
connection con2;
--echo 'T3'
reap;
connection con2;
--echo 'T3'
SET DEBUG_SYNC='row_select_wait WAIT_FOR waiting1';
--send SELECT * FROM t2;
connection default;
--echo 'T2'
SET DEBUG_SYNC='now SIGNAL waiting1';
--echo 'Signalled T3'
connection con2;
--echo 'T3'
reap;
disconnect con2;
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t1;
DROP TABLE t2;
......@@ -176,8 +139,7 @@ DROP TABLE t2;
--echo # Bug 21433768: NON-REPEATABLE READ WITH REPEATABLE READ ISOLATION
--echo #
--connect (con1,localhost,root,,)
connection con1;
CREATE TABLE t1(col1 INT PRIMARY KEY, col2 INT) ENGINE = InnoDB;
INSERT INTO t1 values (1, 0), (2, 0);
SELECT * FROM t1 ORDER BY col1;
......@@ -200,9 +162,7 @@ reap;
disconnect con1;
connection default;
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
# Clean up resources used in this test case.
SET DEBUG_SYNC= 'RESET';
--source include/wait_until_count_sessions.inc
#
# Test that user data is correctly "visualized" in
# INFORMATION_SCHEMA.innodb_locks.lock_data
#
-- source include/have_innodb.inc
SET @save_timeout=@@GLOBAL.innodb_lock_wait_timeout;
SET GLOBAL innodb_lock_wait_timeout=100000000;
let $table_def =
(
c01 TINYINT,
c02 TINYINT UNSIGNED,
c03 SMALLINT,
c04 SMALLINT UNSIGNED,
c05 MEDIUMINT,
c06 MEDIUMINT UNSIGNED,
c07 INT,
c08 INT UNSIGNED,
c09 BIGINT,
c10 BIGINT UNSIGNED,
PRIMARY KEY(c01, c02, c03, c04, c05, c06, c07, c08, c09, c10)
) ENGINE=INNODB;
-- eval CREATE TABLE t_min $table_def;
INSERT INTO t_min VALUES
(-128, 0,
-32768, 0,
-8388608, 0,
-2147483648, 0,
-9223372036854775808, 0);
-- eval CREATE TABLE t_max $table_def;
INSERT INTO t_max VALUES
(127, 255,
32767, 65535,
8388607, 16777215,
2147483647, 4294967295,
9223372036854775807, 18446744073709551615);
CREATE TABLE ```t'\"_str` (
c1 VARCHAR(32),
c2 VARCHAR(32),
c3 VARCHAR(32),
c4 VARCHAR(32),
c5 VARCHAR(32),
c6 VARCHAR(32),
c7 VARCHAR(32),
PRIMARY KEY(c1, c2, c3, c4, c5, c6, c7)
) ENGINE=INNODB;
INSERT INTO ```t'\"_str` VALUES
('1', 'abc', '''abc', 'abc''', 'a''bc', 'a''bc''', '''abc''''');
INSERT INTO ```t'\"_str` VALUES
('2', 'abc', '"abc', 'abc"', 'a"bc', 'a"bc"', '"abc""');
INSERT INTO ```t'\"_str` VALUES
('3', 'abc', '\\abc', 'abc\\', 'a\\bc', 'a\\bc\\', '\\abc\\\\');
INSERT INTO ```t'\"_str` VALUES
('4', 'abc', 0x00616263, 0x61626300, 0x61006263, 0x6100626300, 0x610062630000);
-- source include/count_sessions.inc
-- connect (con_lock,localhost,root,,)
-- connect (con_min_trylock,localhost,root,,)
-- connect (con_max_trylock,localhost,root,,)
-- connect (con_str_insert_supremum,localhost,root,,)
-- connect (con_str_lock_row1,localhost,root,,)
-- connect (con_str_lock_row2,localhost,root,,)
-- connect (con_str_lock_row3,localhost,root,,)
-- connect (con_str_lock_row4,localhost,root,,)
-- connect (con_verify_innodb_locks,localhost,root,,)
-- connection con_lock
SET autocommit=0;
SELECT * FROM t_min FOR UPDATE;
SELECT * FROM t_max FOR UPDATE;
SELECT * FROM ```t'\"_str` FOR UPDATE;
-- connection con_min_trylock
-- send
SELECT * FROM t_min FOR UPDATE;
-- connection con_max_trylock
-- send
SELECT * FROM t_max FOR UPDATE;
-- connection con_str_insert_supremum
-- send
INSERT INTO ```t'\"_str` VALUES
('z', 'z', 'z', 'z', 'z', 'z', 'z');
-- connection con_str_lock_row1
-- send
SELECT * FROM ```t'\"_str` WHERE c1 = '1' FOR UPDATE;
-- connection con_str_lock_row2
-- send
SELECT * FROM ```t'\"_str` WHERE c1 = '2' FOR UPDATE;
-- connection con_str_lock_row3
-- send
SELECT * FROM ```t'\"_str` WHERE c1 = '3' FOR UPDATE;
-- connection con_str_lock_row4
-- send
SELECT * FROM ```t'\"_str` WHERE c1 = '4' FOR UPDATE;
-- connection con_verify_innodb_locks
# Wait for the above queries to execute before continuing.
# Without this, it sometimes happens that the SELECT from innodb_locks
# executes before some of them, resulting in less than expected number
# of rows being selected from innodb_locks. If there is a bug and there
# are no 14 rows in innodb_locks then this test will fail with timeout.
# Notice that if we query INNODB_LOCKS more often than once per 0.1 sec
# then its contents will never change because the cache from which it is
# filled is updated only if it has not been read for 0.1 seconds. See
# CACHE_MIN_IDLE_TIME_US in trx/trx0i_s.c.
let $cnt=10;
while ($cnt)
{
let $success=`SELECT COUNT(*) = 14 FROM INFORMATION_SCHEMA.INNODB_LOCKS`;
if ($success)
{
let $cnt=0;
}
if (!$success)
{
real_sleep 0.2;
dec $cnt;
}
}
if (!$success)
{
-- echo Timeout waiting for rows in INNODB_LOCKS to appear
}
SELECT lock_mode, lock_type, lock_table, lock_index, lock_rec, lock_data
FROM INFORMATION_SCHEMA.INNODB_LOCKS ORDER BY lock_data;
SELECT lock_table, COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS
GROUP BY lock_table;
set @save_sql_mode = @@sql_mode;
SET SQL_MODE='ANSI_QUOTES';
SELECT lock_table, COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS
GROUP BY lock_table;
SET @@sql_mode=@save_sql_mode;
# Release all the locks;
-- connection con_lock
COMMIT;
-- connection default
-- disconnect con_lock
-- disconnect con_min_trylock
-- disconnect con_max_trylock
-- disconnect con_str_insert_supremum
-- disconnect con_str_lock_row1
-- disconnect con_str_lock_row2
-- disconnect con_str_lock_row3
-- disconnect con_str_lock_row4
-- disconnect con_verify_innodb_locks
DROP TABLE t_min, t_max, ```t'\"_str`;
-- source include/wait_until_count_sessions.inc
SET GLOBAL innodb_lock_wait_timeout=@save_timeout;
--source include/have_innodb.inc
#
# Test that transaction data is correctly "visualized" in
# INFORMATION_SCHEMA.INNODB_TRX
#
SET @save_timeout=@@GLOBAL.innodb_lock_wait_timeout;
SET GLOBAL innodb_lock_wait_timeout=100000000;
DESCRIBE INFORMATION_SCHEMA.INNODB_TRX;
CREATE TABLE t1 (
c01 INT,
c02 INT,
PRIMARY KEY (c01)
) ENGINE=INNODB STATS_AUTO_RECALC=0;
INSERT INTO t1 VALUES
(1,2),(2,4),(3,6),(4,8);
CREATE TABLE t2 (
c01 INT,
c02 INT,
PRIMARY KEY (c01),
FOREIGN KEY fk1 (c02) REFERENCES t1 (c01)
) ENGINE=INNODB STATS_AUTO_RECALC=0;
INSERT INTO t2 VALUES
(1,1),(2,2),(3,3);
-- source include/count_sessions.inc
-- connect (con_trx,localhost,root,,)
-- connect (con_verify_innodb_trx,localhost,root,,)
-- connection con_trx
SET autocommit=0;
INSERT INTO t1 VALUES (5,10);
SELECT * FROM t1 FOR UPDATE;
let $wait_timeout= 300;
let $wait_condition=
SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_TRX;
-- source include/wait_condition.inc
-- connection con_verify_innodb_trx
SELECT trx_state, trx_weight, trx_tables_in_use, trx_tables_locked,
trx_rows_locked, trx_rows_modified, trx_concurrency_tickets,
trx_isolation_level, trx_unique_checks, trx_foreign_key_checks
FROM INFORMATION_SCHEMA.INNODB_TRX;
-- connection con_trx
ROLLBACK;
SET FOREIGN_KEY_CHECKS = 0;
SET UNIQUE_CHECKS = 0;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN;
INSERT INTO t1 VALUES (6,12);
let $wait_timeout= 300;
let $wait_condition=
SELECT trx_unique_checks = 0 FROM INFORMATION_SCHEMA.INNODB_TRX;
-- source include/wait_condition.inc
-- connection con_verify_innodb_trx
SELECT trx_isolation_level, trx_unique_checks, trx_foreign_key_checks
FROM INFORMATION_SCHEMA.INNODB_TRX;
-- connection con_trx
ROLLBACK;
SET FOREIGN_KEY_CHECKS = 1;
SET UNIQUE_CHECKS = 1;
BEGIN;
--error ER_NO_REFERENCED_ROW_2
INSERT INTO t2 VALUES (4,10);
let $wait_timeout= 300;
let $wait_condition=
SELECT trx_unique_checks = 1 FROM INFORMATION_SCHEMA.INNODB_TRX;
-- source include/wait_condition.inc
-- disconnect con_trx
-- connection con_verify_innodb_trx
SELECT trx_state, trx_isolation_level, trx_last_foreign_key_error
FROM INFORMATION_SCHEMA.INNODB_TRX;
-- disconnect con_verify_innodb_trx
-- connection default
DROP TABLE t2;
DROP TABLE t1;
-- source include/wait_until_count_sessions.inc
SET GLOBAL innodb_lock_wait_timeout=@save_timeout;
......@@ -27,3 +27,4 @@
--loose-innodb_buffer_pool_pages
--loose-innodb_buffer_pool_pages_index
--loose-innodb_buffer_pool_pages_blob
--innodb-open-files=1000000
-- source include/have_innodb.inc
-- source include/not_embedded.inc
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
let SEARCH_PATTERN= \[Warning\] InnoDB: innodb_open_files 1000000 should not be greater than the open_files_limit [0-9]+;
--source include/search_pattern_in_file.inc
#
# MDEV-7762 InnoDB: Failing assertion: block->page.buf_fix_count > 0 in buf0buf.ic line 730
#
......
#
# Test the persistent stats auto recalc
#
-- source include/have_innodb.inc
# Page numbers printed by this test depend on the page size
-- source include/have_innodb_16k.inc
-- vertical_results
-- let $check_stats1 = SELECT n_rows, clustered_index_size FROM mysql.innodb_table_stats WHERE table_name = 'autorecalc'
-- let $check_stats2 = SELECT index_name, stat_name, stat_value FROM mysql.innodb_index_stats WHERE table_name = 'autorecalc'
CREATE TABLE autorecalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB;
# the CREATE should have inserted zeroed stats
-- eval $check_stats1
-- eval $check_stats2
INSERT INTO autorecalc VALUES (1);
INSERT INTO autorecalc VALUES (2);
# wait for the bg stats thread to update the stats, notice we wait on
# innodb_index_stats because innodb_table_stats gets updated first and
# it is possible that (if we wait on innodb_table_stats) the wait cond
# gets satisfied before innodb_index_stats is updated
let $wait_condition = SELECT stat_value = 2 FROM mysql.innodb_index_stats WHERE table_name = 'autorecalc' AND index_name = 'PRIMARY' AND stat_name = 'n_diff_pfx01';
-- source include/wait_condition.inc
# the second INSERT from above should have triggered an auto-recalc
-- eval $check_stats1
-- eval $check_stats2
# now DELETE the rows and trigger a second auto-recalc, InnoDB may wait a
# few seconds before triggering an auto-recalc again (it tries not to be too
# aggressive)
DELETE FROM autorecalc;
let $wait_timeout = 25;
let $wait_condition = SELECT stat_value = 0 FROM mysql.innodb_index_stats WHERE table_name = 'autorecalc' AND index_name = 'PRIMARY' AND stat_name = 'n_diff_pfx01';
-- source include/wait_condition.inc
# the DELETE from above should have triggered an auto-recalc
-- eval $check_stats1
-- eval $check_stats2
DROP TABLE autorecalc;
#
# Test the persistent stats auto recalc during DDL
#
-- source include/have_innodb.inc
-- vertical_results
-- let $check_stats1 = SELECT n_rows FROM mysql.innodb_table_stats WHERE table_name = 'arddl' ORDER BY 1
-- let $check_stats2 = SELECT index_name, stat_name, stat_value FROM mysql.innodb_index_stats WHERE table_name = 'arddl' AND index_name = 'PRIMARY' ORDER BY 1, 2, 3
# Test ADD INDEX during background stats gathering
CREATE TABLE arddl (a INT, b INT, PRIMARY KEY (a)) ENGINE=INNODB;
INSERT INTO arddl VALUES (1, 10);
INSERT INTO arddl VALUES (2, 10);
ALTER TABLE arddl ADD INDEX (b);
# wait for the bg stats thread to update the stats, notice we wait on
# innodb_index_stats because innodb_table_stats gets updated first and
# it is possible that (if we wait on innodb_table_stats) the wait cond
# gets satisfied before innodb_index_stats is updated
let $wait_condition = SELECT stat_value = 2 FROM mysql.innodb_index_stats WHERE table_name = 'arddl' AND index_name = 'PRIMARY' AND stat_name = 'n_diff_pfx01';
-- source include/wait_condition.inc
# the second INSERT from above should have triggered an auto-recalc
-- eval $check_stats1
-- eval $check_stats2
DROP TABLE arddl;
# Test DROP INDEX during background stats gathering
CREATE TABLE arddl (a INT, b INT, PRIMARY KEY (a), KEY (b)) ENGINE=INNODB;
INSERT INTO arddl VALUES (3, 10);
INSERT INTO arddl VALUES (4, 10);
ALTER TABLE arddl DROP INDEX b;
let $wait_condition = SELECT stat_value = 2 FROM mysql.innodb_index_stats WHERE table_name = 'arddl' AND index_name = 'PRIMARY' AND stat_name = 'n_diff_pfx01';
-- source include/wait_condition.inc
-- eval $check_stats1
-- eval $check_stats2
DROP TABLE arddl;
#
# Test the persistent stats auto recalc on lots of tables
#
--source include/no_valgrind_without_big.inc
-- source include/have_innodb.inc
let $check_stats = SELECT table_name, n_rows FROM mysql.innodb_table_stats WHERE table_name LIKE 'ar_%' ORDER BY table_name;
-- disable_query_log
let $i = 1200;
while ($i > 1000) {
eval CREATE TABLE ar_$i (a INT, PRIMARY KEY (a)) ENGINE=INNODB;
dec $i;
}
-- enable_query_log
# the CREATEs above should have inserted zeroed stats
-- eval $check_stats
-- disable_query_log
let $i = 1200;
while ($i > 1000) {
eval INSERT INTO ar_$i VALUES (1), (2);
dec $i;
}
-- enable_query_log
-- disable_query_log
let $i = 1200;
while ($i > 1000) {
eval INSERT INTO ar_$i VALUES (3), (4);
dec $i;
}
-- enable_query_log
# would be too long to wait for stats to become up to date here
-- disable_query_log
let $i = 1200;
while ($i > 1000) {
eval DROP TABLE ar_$i;
dec $i;
}
-- enable_query_log
#
# Test the persistent stats auto recalc when persistent stats do not exist
#
-- source include/have_innodb.inc
-- vertical_results
-- let $check_stats1 = SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't'
-- let $check_stats2 = SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't'
-- echo Test with default setting
CREATE TABLE t (a INT, PRIMARY KEY (a)) ENGINE=INNODB;
# the CREATE should have inserted zeroed stats
-- eval $check_stats1
-- eval $check_stats2
# close the table
FLUSH TABLE t;
DELETE FROM mysql.innodb_index_stats WHERE table_name = 't';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 't';
-- eval $check_stats1
-- eval $check_stats2
# open the table, causing stats recalc/save
SELECT * FROM t;
-- eval $check_stats1
-- eval $check_stats2
DROP TABLE t;
-- echo Test with explicit enable
CREATE TABLE t (a INT, PRIMARY KEY (a)) ENGINE=INNODB STATS_AUTO_RECALC=1;
# the CREATE should have inserted zeroed stats
-- eval $check_stats1
-- eval $check_stats2
# close the table
FLUSH TABLE t;
DELETE FROM mysql.innodb_index_stats WHERE table_name = 't';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 't';
-- eval $check_stats1
-- eval $check_stats2
# open the table, causing stats recalc/save
SELECT * FROM t;
-- eval $check_stats1
-- eval $check_stats2
DROP TABLE t;
-- echo Test with explicit disable
CREATE TABLE t (a INT, PRIMARY KEY (a)) ENGINE=INNODB STATS_AUTO_RECALC=0;
# the CREATE should have inserted zeroed stats
-- eval $check_stats1
-- eval $check_stats2
# close the table
FLUSH TABLE t;
DELETE FROM mysql.innodb_index_stats WHERE table_name = 't';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 't';
-- eval $check_stats1
-- eval $check_stats2
# open the table, stats should not be present, since autorecalc is disabled
SELECT * FROM t;
-- eval $check_stats1
-- eval $check_stats2
DROP TABLE t;
#
# Bug#18384390 WRONG STATISTICS WITH BIG ROW LENGTH AND PERSISTENT STATS
#
--source include/have_innodb.inc
--source include/have_innodb_max_16k.inc
--source include/have_sequence.inc
CREATE TABLE bug18384390 (
id INT AUTO_INCREMENT PRIMARY KEY,
txt VARCHAR(10000)
) ENGINE=INNODB STATS_PERSISTENT=1 STATS_AUTO_RECALC=0;
let $count=1024;
eval
INSERT INTO bug18384390 (txt) SELECT REPEAT('0', 10000) FROM seq_1_to_$count;
set use_stat_tables=never;
ANALYZE TABLE bug18384390;
-- let $n_rows = `SELECT n_rows FROM mysql.innodb_table_stats WHERE table_name = 'bug18384390'`
-- let $table_rows = `SELECT table_rows FROM information_schema.tables WHERE table_name = 'bug18384390'`
-- let $n_diff = `SELECT stat_value FROM mysql.innodb_index_stats WHERE table_name = 'bug18384390' AND stat_name = 'n_diff_pfx01'`
-- let $cardinality = `SELECT cardinality FROM information_schema.statistics WHERE table_name = 'bug18384390'`
-- let $margin_of_err_pct = 30
-- let $margin_of_err_rows = `SELECT ROUND($count * $margin_of_err_pct / 100)`
-- let $min_allowed = `SELECT $count - $margin_of_err_rows`
-- let $max_allowed = `SELECT $count + $margin_of_err_rows`
-- let $dump_sql = SELECT COUNT(*) FROM bug18384390; SELECT * FROM mysql.innodb_table_stats; SELECT * FROM mysql.innodb_index_stats; SELECT * FROM information_schema.tables WHERE table_name = 'bug18384390'; SELECT * FROM information_schema.statistics WHERE table_name = 'bug18384390';
-- vertical_results
if ($n_rows < $min_allowed) {
-- echo mysql.innodb_table_stats.n_rows is too small ($n_rows < $min_allowed)
-- eval $dump_sql
}
if ($n_rows > $max_allowed) {
-- echo mysql.innodb_table_stats.n_rows is too big ($n_rows > $max_allowed)
-- eval $dump_sql
}
if ($table_rows < $min_allowed) {
-- echo information_schema.tables.table_rows is too small ($table_rows < $min_allowed)
-- eval $dump_sql
}
if ($table_rows > $max_allowed) {
-- echo information_schema.tables.table_rows is too big ($table_rows > $max_allowed)
-- eval $dump_sql
}
if ($n_diff < $min_allowed) {
-- echo mysql.innodb_index_stats.stat_value is too small ($n_diff < $min_allowed)
-- eval $dump_sql
}
if ($n_diff > $max_allowed) {
-- echo mysql.innodb_index_stats.stat_value is too big ($n_diff > $max_allowed)
-- eval $dump_sql
}
if ($cardinality < $min_allowed) {
-- echo information_schema.statistics.cardinality is too small ($cardinality < $min_allowed)
-- eval $dump_sql
}
if ($cardinality > $max_allowed) {
-- echo information_schema.statistics.cardinality is too big ($cardinality > $max_allowed)
-- eval $dump_sql
}
DROP TABLE bug18384390;
[on]
--innodb-stats-persistent=1
[off]
--innodb-stats-persistent=0
-- source include/have_innodb.inc
-- source include/not_embedded.inc
#
-- echo =====
-- echo === Test ANALYZE behavior after default creation
-- echo =====
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB;
-- source innodb_stats_flag_global_analyze.inc
DROP TABLE test_ps_flag;
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=default;
-- source innodb_stats_flag_global_analyze.inc
DROP TABLE test_ps_flag;
#
-- echo =====
-- echo === Test ANALYZE behavior after creation with explicit PS=OFF
-- echo =====
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=0;
-- source innodb_stats_flag_global_analyze.inc
DROP TABLE test_ps_flag;
#
-- echo =====
-- echo === Test ANALYZE behavior after creation with explicit PS=ON
-- echo =====
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=1;
-- source innodb_stats_flag_global_analyze.inc
DROP TABLE test_ps_flag;
#
-- echo =====
-- echo === Test ANALYZE behavior after creation with explicit PS=OFF,
-- echo === then ALTER to ON, then ALTER to OFF, then ALTER to default
-- echo =====
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=0;
ALTER TABLE test_ps_flag STATS_PERSISTENT=1;
# also check that the change from the ALTER TABLE survives server restart
-- source include/restart_mysqld.inc
-- source innodb_stats_flag_global_analyze.inc
ALTER TABLE test_ps_flag STATS_PERSISTENT=0;
-- source innodb_stats_flag_global_analyze.inc
ALTER TABLE test_ps_flag STATS_PERSISTENT=default;
-- source innodb_stats_flag_global_analyze.inc
DROP TABLE test_ps_flag;
#
-- echo =====
-- echo === Test ANALYZE behavior after creation with explicit PS=ON,
-- echo === then ALTER to OFF, then ALTER to ON, then ALTER to default
-- echo =====
CREATE TABLE test_ps_flag (a INT) ENGINE=INNODB STATS_PERSISTENT=1;
ALTER TABLE test_ps_flag STATS_PERSISTENT=0;
# also check that the change from the ALTER TABLE survives server restart
-- source include/restart_mysqld.inc
-- source innodb_stats_flag_global_analyze.inc
ALTER TABLE test_ps_flag STATS_PERSISTENT=1;
-- source innodb_stats_flag_global_analyze.inc
ALTER TABLE test_ps_flag STATS_PERSISTENT=default;
-- source innodb_stats_flag_global_analyze.inc
DROP TABLE test_ps_flag;
SHOW CREATE TABLE test_ps_flag;
DELETE FROM mysql.innodb_index_stats WHERE table_name = 'test_ps_flag';
DELETE FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
# must be 0, we have just deleted the rows
SELECT COUNT(*) AS cnt_before FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE test_ps_flag;
# if the table is PS enabled, then this should be 1 and 0 otherwise
SELECT COUNT(*) AS cnt_after FROM mysql.innodb_table_stats WHERE table_name = 'test_ps_flag';
......@@ -15,6 +15,7 @@ ENGINE=INNODB STATS_PERSISTENT=1,STATS_AUTO_RECALC=1;
CREATE TABLE t2 LIKE t1;
INSERT INTO t1 (val) SELECT 4 FROM seq_1_to_16;
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE t1;
connect(con1, localhost, root,,);
......@@ -85,3 +86,41 @@ SET GLOBAL innodb_stats_include_delete_marked = @saved_include_delete_marked;
SET GLOBAL innodb_stats_traditional = @saved_traditional;
SET GLOBAL innodb_stats_modified_counter = @saved_modified_counter;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
#
# Bug#12429573 TIMESTAMP COLUMN OF INNODB.INDEX_STATS ARE NOT UPDATED
# WHEN RE-RUNNING ANALYZE
#
CREATE TABLE bug12429573 (i INTEGER PRIMARY KEY, j INTEGER, KEY(j))
ENGINE=INNODB STATS_PERSISTENT=1;
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE bug12429573;
# Cannot check the exact timestamp here because it is always different
# but at least check that both timestamps in innodb_table_stats and in
# innodb_index_stats have been updated to the same value. If the bug is
# present this check will fail.
SELECT last_update INTO @last FROM mysql.innodb_table_stats
WHERE table_name = 'bug12429573';
SELECT * FROM mysql.innodb_index_stats
WHERE table_name = 'bug12429573' AND last_update!=@last;
# The first ANALYZE would insert timestamp e.g. 17:23:39 in both
# innodb_table_stats and innodb_index_stats. The bug is that the second
# ANALYZE only updates the timestamp in innodb_table_stats. In order to
# check if the timestamp in innodb_index_stats has really been updated we
# need it to be different from the previous one (17:23:39) with at least
# one second.
-- sleep 1
SET STATEMENT use_stat_tables=never FOR
ANALYZE TABLE bug12429573;
SELECT * FROM mysql.innodb_table_stats
WHERE table_name = 'bug12429573' AND last_update=@last;
SELECT * FROM mysql.innodb_index_stats
WHERE table_name = 'bug12429573' AND last_update=@last;
DROP TABLE bug12429573;
#
# Test that the table option STATS_SAMPLE_PAGES=N|default is indeed
# used by InnoDB
#
-- source include/have_innodb.inc
# Page numbers printed by this test depend on the page size
-- source include/have_innodb_16k.inc
SET GLOBAL innodb_stats_persistent_sample_pages=17;
CREATE TABLE test_ps_sample_pages_used (
a VARCHAR(512), PRIMARY KEY (a)
) ENGINE=INNODB STATS_SAMPLE_PAGES=default;
# Insert enough records into the table so that it has more than 2*17+1 pages
# If we ask to scan more than the half of the leaf pages, then the sampling
# will do full scan and we cannot check whether the sample_pages variable was
# honored.
BEGIN;
-- disable_query_log
let $i=999;
while ($i) {
eval INSERT INTO test_ps_sample_pages_used VALUES (REPEAT(1000+$i, 128));
dec $i;
}
-- enable_query_log
COMMIT;
ANALYZE TABLE test_ps_sample_pages_used;
# confirm the big number of leaf pages in the index
SELECT stat_name, stat_value FROM mysql.innodb_index_stats
WHERE table_name='test_ps_sample_pages_used' AND stat_name='n_leaf_pages';
# confirm that 17 pages were sampled, that is - the global
# innodb_stats_persistent_sample_pages is used when the table option
# STATS_SAMPLE_PAGES is set to 'default'.
SELECT sample_size FROM mysql.innodb_index_stats
WHERE table_name='test_ps_sample_pages_used' AND stat_name='n_diff_pfx01';
ALTER TABLE test_ps_sample_pages_used STATS_SAMPLE_PAGES=14;
ANALYZE TABLE test_ps_sample_pages_used;
# confirm that 14 pages were sampled, that is - the table option
# STATS_SAMPLE_PAGES is used when it is set.
SELECT sample_size FROM mysql.innodb_index_stats
WHERE table_name='test_ps_sample_pages_used' AND stat_name='n_diff_pfx01';
DROP TABLE test_ps_sample_pages_used;
SET GLOBAL innodb_stats_persistent_sample_pages=default;
#
# Test CREATE TABLE ... STATS_AUTO_RECALC=0|1|default
#
-- source include/no_valgrind_without_big.inc
-- source include/have_innodb.inc
-- source include/not_embedded.inc
-- vertical_results
CREATE TABLE test_ps_auto_recalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB;
SHOW CREATE TABLE test_ps_auto_recalc;
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_auto_recalc';
ALTER TABLE test_ps_auto_recalc STATS_AUTO_RECALC=1;
# confirm that the flag survives server restart
-- source include/restart_mysqld.inc
SHOW CREATE TABLE test_ps_auto_recalc;
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_auto_recalc';
DROP TABLE test_ps_auto_recalc;
##
CREATE TABLE test_ps_auto_recalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_AUTO_RECALC=default;
SHOW CREATE TABLE test_ps_auto_recalc;
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_auto_recalc';
DROP TABLE test_ps_auto_recalc;
##
CREATE TABLE test_ps_auto_recalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_AUTO_RECALC=0;
# confirm that the flag survives server restart
-- source include/restart_mysqld.inc
SHOW CREATE TABLE test_ps_auto_recalc;
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_auto_recalc';
ALTER TABLE test_ps_auto_recalc STATS_AUTO_RECALC=1;
# confirm that the flag survives server restart
-- source include/restart_mysqld.inc
SHOW CREATE TABLE test_ps_auto_recalc;
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_auto_recalc';
DROP TABLE test_ps_auto_recalc;
##
CREATE TABLE test_ps_auto_recalc (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_AUTO_RECALC=1;
# confirm that the flag survives server restart
-- source include/restart_mysqld.inc
SHOW CREATE TABLE test_ps_auto_recalc;
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_auto_recalc';
ALTER TABLE test_ps_auto_recalc STATS_AUTO_RECALC=0;
# confirm that the flag survives server restart
-- source include/restart_mysqld.inc
SHOW CREATE TABLE test_ps_auto_recalc;
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_auto_recalc';
DROP TABLE test_ps_auto_recalc;
#
# Test CREATE TABLE ... STATS_SAMPLE_PAGES=N|default
#
-- source include/have_innodb.inc
# include/restart_mysqld.inc does not work in embedded mode
-- source include/not_embedded.inc
-- vertical_results
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB;
SHOW CREATE TABLE test_ps_sample_pages;
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_sample_pages';
ALTER TABLE test_ps_sample_pages STATS_SAMPLE_PAGES=12345;
# confirm that the flag survives server restart
-- source include/restart_mysqld.inc
SHOW CREATE TABLE test_ps_sample_pages;
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_sample_pages';
DROP TABLE test_ps_sample_pages;
##
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=default;
SHOW CREATE TABLE test_ps_sample_pages;
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_sample_pages';
DROP TABLE test_ps_sample_pages;
##
-- error ER_PARSE_ERROR
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=-5;
-- error ER_PARSE_ERROR
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=0;
-- error ER_PARSE_ERROR
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=67000;
-- error ER_PARSE_ERROR
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=670000;
-- error ER_PARSE_ERROR
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=65536;
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=65535;
SHOW CREATE TABLE test_ps_sample_pages;
DROP TABLE test_ps_sample_pages;
##
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=1;
# confirm that the flag survives server restart
-- source include/restart_mysqld.inc
SHOW CREATE TABLE test_ps_sample_pages;
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_sample_pages';
DROP TABLE test_ps_sample_pages;
##
CREATE TABLE test_ps_sample_pages (a INT, PRIMARY KEY (a)) ENGINE=INNODB
STATS_SAMPLE_PAGES=5678;
# confirm that the flag survives server restart
-- source include/restart_mysqld.inc
SHOW CREATE TABLE test_ps_sample_pages;
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_sample_pages';
ALTER TABLE test_ps_sample_pages STATS_SAMPLE_PAGES=default;
# confirm that the flag survives server restart
-- source include/restart_mysqld.inc
SHOW CREATE TABLE test_ps_sample_pages;
SELECT create_options FROM information_schema.tables
WHERE table_name='test_ps_sample_pages';
DROP TABLE test_ps_sample_pages;
#
# Test ut_format_name()
#
-- source include/have_debug.inc
-- source include/have_innodb.inc
CREATE TABLE t (c INT) ENGINE=INNODB;
# This will invoke test_ut_format_name() in debug builds
SET @save_dbug = @@debug_dbug;
SET debug_dbug = '+d,test_ut_format_name';
DROP TABLE t;
SET debug_dbug = @save_dbug;
This diff is collapsed.
--innodb-sys-tablespaces
--innodb-sys-datafiles
--innodb-sys-tablespaces
--innodb-sys-datafiles
--echo #
--echo # Test the limits of a file-per-table tablespace name. MySQL combines
--echo # the database name with the table name to make a unique table name.
--echo #
# There is no use in testing the maximum expanded filename using "#" or
# some other character that is expanded by MySQL to "@0023" because
# Windows imposes a maximum absolute path length of 260 bytes. So the
# results will depend upon what local directory this test is run in.
# See https://msdn.microsoft.com/en-us/library/aa365247.aspx
# "Maximum Path Length Limitation
# In the Windows API, the maximum length for a path is MAX_PATH, which is
# defined as 260 characters. A local path is structured in the following
# order: drive letter, colon, backslash, name components separated by
# backslashes, and a terminating null character. For example, the maximum
# path on drive D is "D:\some 256-character path string<NUL>" where
# "<NUL>" represents the invisible terminating null character for the
# current system codepage. (The characters < > are used here for visual
# clarity and cannot be part of a valid path string.)"
--source include/have_innodb.inc
--source include/windows.inc
# This will test the limit of a filename in MySQL at 512 bytes.
# We control that by making it a relative path starting with "./".
# The embedded server uses an absolute path as the datadir
# which has a non-deterministic length.
--source include/not_embedded.inc
SET default_storage_engine=InnoDB;
LET $MYSQLD_DATADIR = `select @@datadir`;
--echo #
--echo # MySQL limits each database and tablename identifier to 64 characters
--echo # of up to 3 bytes per character, corresponding to 192 bytes.
--echo #
LET $too_long_name = this_sixty_five_byte_name_is_too_long____________________________;
--error ER_WRONG_DB_NAME
--eval CREATE DATABASE `$too_long_name`
LET $long_name = this_sixty_four_byte_name_is_not_too_long_______________________;
--eval CREATE DATABASE `$long_name`
--eval USE `$long_name`
--echo #
--echo # A 64 character tablename can be created in a 64 character database name
--echo #
--eval CREATE TABLE `$long_name`.`$long_name` (a SERIAL)
--echo #
--echo # A 65 character tablename is too long.
--echo #
--error ER_WRONG_TABLE_NAME
--eval CREATE TABLE `test`.`$too_long_name` (a SERIAL)
--error ER_WRONG_TABLE_NAME
--eval CREATE TABLE `$long_name`.`$too_long_name` (a SERIAL)
--echo #
--echo # Show the successfully created database and table
--echo #
--eval SHOW CREATE TABLE `$long_name`.`$long_name`
--echo ---- list_files MYSQLD_DATADIR/$long_name
--list_files $MYSQLD_DATADIR/$long_name
SELECT name FROM information_schema.innodb_sys_tables WHERE name LIKE '%long%';
SELECT name FROM information_schema.innodb_sys_tablespaces WHERE name LIKE '%long%';
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
SELECT path FROM information_schema.innodb_sys_datafiles WHERE path LIKE '%long%';
--vertical_results
--replace_regex /innodb_file_per_table_[0-9]*/innodb_file_per_table_##/
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
SELECT file_name, tablespace_name FROM information_schema.files WHERE file_name LIKE '%long%';
--horizontal_results
--echo #
--echo # Cleanup
--echo #
--eval DROP DATABASE `$long_name`
CREATE TABLE t1 (
id INT NOT NULL,
title TEXT,
PRIMARY KEY (id),
FULLTEXT KEY (title),
FOREIGN KEY (id) REFERENCES t2 (id)
) ENGINE=InnoDB;
ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed")
CREATE TABLE t1 (
id INT NOT NULL,
title TEXT,
PRIMARY KEY (id)
) ENGINE=InnoDB;
ALTER TABLE t1 ADD FULLTEXT KEY (title), ADD FOREIGN KEY (id) REFERENCES t2 (id);
ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed")
SET FOREIGN_KEY_CHECKS = 0;
ALTER TABLE t1 ADD FULLTEXT KEY (title), ADD FOREIGN KEY (id) REFERENCES t2 (id);
DROP TABLE t1;
CREATE TABLE t1 (
id INT NOT NULL,
title TEXT,
PRIMARY KEY (id),
FULLTEXT KEY (title),
FOREIGN KEY (id) REFERENCES t2 (id)
) ENGINE=InnoDB;
DROP TABLE t1;
SET FOREIGN_KEY_CHECKS = 1;
This diff is collapsed.
This diff is collapsed.
......@@ -134,6 +134,7 @@ count(*)
2
DROP TABLE t1;
set global innodb_file_per_table=1;
set names utf8;
CREATE TABLE t1 (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
a TEXT,
......@@ -160,7 +161,7 @@ SELECT count(*) FROM t1
WHERE MATCH (a,b,c)
AGAINST ('"very blob"@4' IN BOOLEAN MODE);
count(*)
4
5
SELECT count(*) FROM t1
WHERE MATCH (a,b,c)
AGAINST ('"interesting blob"@9' IN BOOLEAN MODE);
......@@ -175,7 +176,7 @@ SELECT COUNT(*) FROM t1
WHERE MATCH (a,b,c)
AGAINST ('"very blob"@4 - "interesting blob"@9' IN BOOLEAN MODE);
COUNT(*)
3
4
DROP TABLE t1;
CREATE TABLE t1 (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
......
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.
--innodb-ft-index-cache
--innodb-ft-index-table
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