MDEV-13626 Merge InnoDB test cases from MySQL 5.7

Imported the following test case from mysql to MariaDB

1) innodb.alter_kill
2) innodb.alter_foreign_crash
3) innodb.alter_rename_files
4) innodb.analyze_table
5) Appended the case in innodb-online-alter-gis
parents 6f4534e6 a54b581d
#
# Bug #20476395 DICT_LOAD_FOREIGNS() FAILED IN
# COMMIT_INPLACE_ALTER_TABLE
#
call mtr.add_suppression("InnoDB: Failed to load table");
create database bug;
use bug;
create table parent(a serial) engine=innodb;
create table child(a serial, foreign key fk (a) references parent(a))engine=innodb;
insert into parent values(1);
insert into child values(1);
connect con1,localhost,root,,bug;
SET DEBUG_SYNC='innodb_rename_table_ready SIGNAL s1 WAIT_FOR s2 EXECUTE 2';
ALTER TABLE child ROW_FORMAT=DYNAMIC, ALGORITHM=COPY;
connection default;
SET DEBUG_SYNC='now WAIT_FOR s1';
SET DEBUG_SYNC='now SIGNAL s2 WAIT_FOR s1';
disconnect con1;
show tables;
Tables_in_bug
parent
alter table parent row_format=dynamic;
Warnings:
Warning 1088 InnoDB: Could not add foreign key constraints.
drop table parent;
drop database bug;
#
# Bug#16720368 INNODB CRASHES ON BROKEN #SQL*.IBD FILE AT STARTUP
#
SET GLOBAL innodb_file_per_table=1;
CREATE TABLE bug16720368_1 (a INT PRIMARY KEY) ENGINE=InnoDB;
connect con1,localhost,root;
CREATE TABLE bug16720368 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
INSERT INTO bug16720368 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8);
connection default;
# Cleanly shutdown mysqld
disconnect con1;
# Corrupt FIL_PAGE_OFFSET in bug16720368.ibd,
# and update the checksum to the "don't care" value.
# Restart mysqld
# This will succeed after a clean shutdown, due to
# fil_open_single_table_tablespace(check_space_id=FALSE).
SELECT COUNT(*) FROM bug16720368;
COUNT(*)
8
INSERT INTO bug16720368_1 VALUES(1);
# The table is unaccessible, because after a crash we will
# validate the tablespace header.
SELECT COUNT(*) FROM bug16720368;
ERROR 42S02: Table 'test.bug16720368' doesn't exist in engine
INSERT INTO bug16720368 VALUES(0,1);
ERROR 42S02: Table 'test.bug16720368' doesn't exist in engine
# The table is readable thanks to innodb-force-recovery.
SELECT COUNT(*) FROM bug16720368;
COUNT(*)
8
INSERT INTO bug16720368 VALUES(0,1);
# Shut down the server cleanly to hide the corruption.
# The table is accessible, because after a clean shutdown we will
# NOT validate the tablespace header.
# We can modify the existing pages, but we cannot allocate or free
# any pages, because that would hit the corruption on page 0.
SELECT COUNT(*) FROM bug16720368;
COUNT(*)
9
# Shut down the server to uncorrupt the data.
# Restart the server after uncorrupting the file.
INSERT INTO bug16720368 VALUES(9,1);
SELECT COUNT(*) FROM bug16720368;
COUNT(*)
10
DROP TABLE bug16720368, bug16720368_1;
#
# Bug#16735660 ASSERT TABLE2 == NULL, ROLLBACK OF RESURRECTED TXNS,
# DICT_TABLE_ADD_TO_CACHE
#
SET GLOBAL innodb_file_per_table=1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
BEGIN;
INSERT INTO t1 VALUES(42);
connect con1,localhost,root;
CREATE TABLE bug16735660 (a INT PRIMARY KEY) ENGINE=InnoDB;
XA START 'x';
INSERT INTO bug16735660 VALUES(1),(2),(3);
XA END 'x';
XA PREPARE 'x';
connection default;
# Kill the server
disconnect con1;
# Attempt to start without an *.ibd file.
FOUND 1 /\[ERROR\] InnoDB: Tablespace [0-9]+ was not found at .*test.bug16735660.ibd/ in mysqld.1.err
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM bug16735660;
a
1
2
3
XA RECOVER;
formatID gtrid_length bqual_length data
1 1 0 x
XA ROLLBACK 'x';
SELECT * FROM bug16735660;
a
DROP TABLE bug16735660;
CREATE TABLE t1 (x INT NOT NULL UNIQUE KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(5);
SET GLOBAL innodb_log_checkpoint_now=TRUE;
SET DEBUG_SYNC='commit_cache_rebuild SIGNAL ready WAIT_FOR finish';
ALTER TABLE t1 ADD PRIMARY KEY(x);
connect con1,localhost,root,,;
SET DEBUG_SYNC='now WAIT_FOR ready';
SET GLOBAL innodb_log_checkpoint_now=TRUE;
SET DEBUG_SYNC='now SIGNAL finish';
disconnect con1;
connection default;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) NOT NULL,
PRIMARY KEY (`x`),
UNIQUE KEY `x` (`x`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t1;
SET DEBUG_SYNC='RESET';
CREATE PROCEDURE populate_t1()
BEGIN
DECLARE i int DEFAULT 1;
START TRANSACTION;
WHILE (i <= 1000000) DO
INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
SET i = i + 1;
END WHILE;
COMMIT;
END|
CREATE TABLE t1(
class INT,
id INT,
title VARCHAR(100)
) ENGINE=InnoDB;
SELECT COUNT(*) FROM t1;
COUNT(*)
1000000
SET GLOBAL innodb_stats_persistent_sample_pages=2000;
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
DROP TABLE t1;
DROP PROCEDURE populate_t1;
SET GLOBAL innodb_stats_persistent_sample_pages=default;
...@@ -47,3 +47,21 @@ DESCRIBE t1; ...@@ -47,3 +47,21 @@ DESCRIBE t1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
DROP TABLE t1; DROP TABLE t1;
#
# Bug #19077964 ASSERT PAGE_SIZE.EQUALS_TO SPACE_PAGE_SIZE
# BTR_COPY_BLOB_PREFIX
#
CREATE TABLE t1(f1 INT PRIMARY KEY, f3 LINESTRING NOT NULL,
SPATIAL KEY(f3))ENGINE=InnoDB ROW_FORMAT=COMPRESSED
KEY_BLOCK_SIZE=1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) NOT NULL,
`f3` linestring NOT NULL,
PRIMARY KEY (`f1`),
SPATIAL KEY `f3` (`f3`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1
INSERT INTO t1 VALUES (1, ST_linefromtext(concat('linestring', '( 0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7, 8 8, 9 9, 10 10, 11 11, 12 12, 13 13, 14 14, 15 15, 16 16, 17 17, 18 18, 19 19, 20 20, 21 21, 22 22, 23 23, 24 24, 25 25, 26 26, 27 27, 28 28, 29 29, 30 30, 31 31, 32 32, 33 33, 34 34, 35 35, 36 36, 37 37, 38 38, 39 39, 40 40, 41 41, 42 42, 43 43, 44 44, 45 45, 46 46, 47 47, 48 48, 49 49, 50 50, 51 51, 52 52, 53 53, 54 54, 55 55, 56 56, 57 57, 58 58, 59 59, 60 60, 61 61, 62 62, 63 63, 64 64, 65 65, 66 66, 67 67, 68 68, 69 69, 70 70, 71 71, 72 72, 73 73, 74 74, 75 75, 76 76, 77 77, 78 78, 79 79, 9999 9999)')));;
ALTER TABLE t1 ROW_FORMAT = DYNAMIC, KEY_BLOCK_SIZE=0, ALGORITHM=INPLACE;
DROP TABLE t1;
--source include/have_innodb.inc
--source include/have_debug_sync.inc
# The embedded server does not support restarting.
--source include/not_embedded.inc
--echo #
--echo # Bug #20476395 DICT_LOAD_FOREIGNS() FAILED IN
--echo # COMMIT_INPLACE_ALTER_TABLE
--echo #
call mtr.add_suppression("InnoDB: Failed to load table");
create database bug;
use bug;
create table parent(a serial) engine=innodb;
create table child(a serial, foreign key fk (a) references parent(a))engine=innodb;
insert into parent values(1);
insert into child values(1);
connect (con1,localhost,root,,bug);
SET DEBUG_SYNC='innodb_rename_table_ready SIGNAL s1 WAIT_FOR s2 EXECUTE 2';
--send ALTER TABLE child ROW_FORMAT=DYNAMIC, ALGORITHM=COPY
connection default;
SET DEBUG_SYNC='now WAIT_FOR s1';
SET DEBUG_SYNC='now SIGNAL s2 WAIT_FOR s1';
--let $shutdown_timeout= 0
--source include/restart_mysqld.inc
disconnect con1;
show tables;
alter table parent row_format=dynamic;
drop table parent;
drop database bug;
--source include/have_innodb.inc
# The embedded server does not support restarting in mysql-test-run.
-- source include/not_embedded.inc
-- source include/no_valgrind_without_big.inc
let MYSQLD_DATADIR=`select @@datadir`;
let PAGE_SIZE=`select @@innodb_page_size`;
-- disable_query_log
call mtr.add_suppression("InnoDB: innodb_force_recovery is on.");
call mtr.add_suppression("InnoDB: Header page contains inconsistent data in .*bug16720368.ibd");
call mtr.add_suppression("InnoDB: Checksum mismatch in datafile:.*bug16720368");
call mtr.add_suppression("InnoDB: Ignoring tablespace for.*bug16720368");
call mtr.add_suppression("Found 1 prepared XA transactions");
call mtr.add_suppression("InnoDB: Operating system error.*in a file operation");
call mtr.add_suppression("InnoDB: \(The error means\|If you are\)");
call mtr.add_suppression("InnoDB: Ignoring tablespace `test/bug16720368` because it could not be opened");
call mtr.add_suppression("InnoDB: Tablespace .* was not found at.*bug16735660");
call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore this and to permanently lose all changes to the tablespace.");
call mtr.add_suppression("InnoDB: Plugin initialization aborted*");
call mtr.add_suppression("Plugin 'InnoDB' init function returned error.");
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed.");
-- enable_query_log
-- echo #
-- echo # Bug#16720368 INNODB CRASHES ON BROKEN #SQL*.IBD FILE AT STARTUP
-- echo #
SET GLOBAL innodb_file_per_table=1;
CREATE TABLE bug16720368_1 (a INT PRIMARY KEY) ENGINE=InnoDB;
connect (con1,localhost,root);
CREATE TABLE bug16720368 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
INSERT INTO bug16720368 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8);
connection default;
-- echo # Cleanly shutdown mysqld
-- source include/shutdown_mysqld.inc
disconnect con1;
-- echo # Corrupt FIL_PAGE_OFFSET in bug16720368.ibd,
-- echo # and update the checksum to the "don't care" value.
perl;
my $file = "$ENV{MYSQLD_DATADIR}/test/bug16720368.ibd";
open(FILE, "+<$file") || die "Unable to open $file";
print FILE pack("H*","deadbeefc001cafe") || die "Unable to write $file";
seek(FILE, $ENV{PAGE_SIZE}-8, 0) || die "Unable to seek $file";
print FILE pack("H*","deadbeef") || die "Unable to write $file";
close(FILE) || die "Unable to close $file";
EOF
-- echo # Restart mysqld
-- source include/start_mysqld.inc
-- echo # This will succeed after a clean shutdown, due to
-- echo # fil_open_single_table_tablespace(check_space_id=FALSE).
SELECT COUNT(*) FROM bug16720368;
INSERT INTO bug16720368_1 VALUES(1);
--let $shutdown_timeout= 0
--source include/restart_mysqld.inc
-- echo # The table is unaccessible, because after a crash we will
-- echo # validate the tablespace header.
--error ER_NO_SUCH_TABLE_IN_ENGINE
SELECT COUNT(*) FROM bug16720368;
--error ER_NO_SUCH_TABLE_IN_ENGINE
INSERT INTO bug16720368 VALUES(0,1);
let $restart_parameters = --innodb-force-recovery=3;
--let $shutdown_timeout= 0
--source include/restart_mysqld.inc
-- echo # The table is readable thanks to innodb-force-recovery.
SELECT COUNT(*) FROM bug16720368;
INSERT INTO bug16720368 VALUES(0,1);
-- echo # Shut down the server cleanly to hide the corruption.
let $shutdown_timeout=;
let $restart_parameters =;
-- source include/restart_mysqld.inc
-- echo # The table is accessible, because after a clean shutdown we will
-- echo # NOT validate the tablespace header.
-- echo # We can modify the existing pages, but we cannot allocate or free
-- echo # any pages, because that would hit the corruption on page 0.
SELECT COUNT(*) FROM bug16720368;
-- echo # Shut down the server to uncorrupt the data.
-- source include/shutdown_mysqld.inc
# Uncorrupt the FIL_PAGE_OFFSET.
perl;
my $file = "$ENV{MYSQLD_DATADIR}/test/bug16720368.ibd";
open(FILE, "+<$file") || die "Unable to open $file";
# Uncorrupt FIL_PAGE_OFFSET.
print FILE pack("H*","deadbeef00000000") || die "Unable to write $file";
close(FILE) || die "Unable to close $file";
EOF
-- echo # Restart the server after uncorrupting the file.
-- source include/start_mysqld.inc
INSERT INTO bug16720368 VALUES(9,1);
SELECT COUNT(*) FROM bug16720368;
# A debug assertion would fail in buf_block_align_instance()
# if we did not uncorrupt the page number first.
DROP TABLE bug16720368, bug16720368_1;
-- echo #
-- echo # Bug#16735660 ASSERT TABLE2 == NULL, ROLLBACK OF RESURRECTED TXNS,
-- echo # DICT_TABLE_ADD_TO_CACHE
-- echo #
SET GLOBAL innodb_file_per_table=1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
BEGIN;
INSERT INTO t1 VALUES(42);
-- connect (con1,localhost,root)
CREATE TABLE bug16735660 (a INT PRIMARY KEY) ENGINE=InnoDB;
XA START 'x';
INSERT INTO bug16735660 VALUES(1),(2),(3);
XA END 'x';
XA PREPARE 'x';
-- connection default
-- source include/kill_mysqld.inc
-- disconnect con1
-- move_file $MYSQLD_DATADIR/test/bug16735660.ibd $MYSQLD_DATADIR/bug16735660.omg
-- echo # Attempt to start without an *.ibd file.
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
--source include/start_mysqld.inc
let SEARCH_PATTERN= \[ERROR\] InnoDB: Tablespace [0-9]+ was not found at .*test.bug16735660.ibd;
-- source include/search_pattern_in_file.inc
-- move_file $MYSQLD_DATADIR/bug16735660.omg $MYSQLD_DATADIR/test/bug16735660.ibd
-- source include/restart_mysqld.inc
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM bug16735660;
XA RECOVER;
XA ROLLBACK 'x';
SELECT * FROM bug16735660;
DROP TABLE bug16735660;
--source include/have_debug.inc
--source include/have_debug_sync.inc
--source include/have_innodb.inc
--source include/count_sessions.inc
CREATE TABLE t1 (x INT NOT NULL UNIQUE KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(5);
SET GLOBAL innodb_log_checkpoint_now=TRUE;
# Start an ALTER TABLE and stop it before renaming the files
SET DEBUG_SYNC='commit_cache_rebuild SIGNAL ready WAIT_FOR finish';
--send ALTER TABLE t1 ADD PRIMARY KEY(x)
connect (con1,localhost,root,,);
SET DEBUG_SYNC='now WAIT_FOR ready';
SET GLOBAL innodb_log_checkpoint_now=TRUE;
SET DEBUG_SYNC='now SIGNAL finish';
disconnect con1;
connection default;
reap;
SHOW CREATE TABLE t1;
DROP TABLE t1;
SET DEBUG_SYNC='RESET';
--source include/wait_until_count_sessions.inc
#
# BUG#22385442 - INNODB: DIFFICULT TO FIND FREE BLOCKS IN THE BUFFER POOL
#
--source include/have_innodb.inc
--source include/big_test.inc
DELIMITER |;
CREATE PROCEDURE populate_t1()
BEGIN
DECLARE i int DEFAULT 1;
START TRANSACTION;
WHILE (i <= 1000000) DO
INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
SET i = i + 1;
END WHILE;
COMMIT;
END|
DELIMITER ;|
CREATE TABLE t1(
class INT,
id INT,
title VARCHAR(100)
) ENGINE=InnoDB;
-- disable_query_log
CALL populate_t1();
-- enable_query_log
SELECT COUNT(*) FROM t1;
SET GLOBAL innodb_stats_persistent_sample_pages=2000;
ANALYZE TABLE t1;
DROP TABLE t1;
DROP PROCEDURE populate_t1;
SET GLOBAL innodb_stats_persistent_sample_pages=default;
...@@ -29,3 +29,34 @@ CREATE TABLE t1 (a INT) ENGINE=InnoDB; ...@@ -29,3 +29,34 @@ CREATE TABLE t1 (a INT) ENGINE=InnoDB;
ALTER TABLE t1 ADD COLUMN b LINESTRING DEFAULT POINT(1,1); ALTER TABLE t1 ADD COLUMN b LINESTRING DEFAULT POINT(1,1);
DESCRIBE t1; DESCRIBE t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug #19077964 ASSERT PAGE_SIZE.EQUALS_TO SPACE_PAGE_SIZE
--echo # BTR_COPY_BLOB_PREFIX
--echo #
CREATE TABLE t1(f1 INT PRIMARY KEY, f3 LINESTRING NOT NULL,
SPATIAL KEY(f3))ENGINE=InnoDB ROW_FORMAT=COMPRESSED
KEY_BLOCK_SIZE=1;
SHOW CREATE TABLE t1;
let $points = 80;
let $x = 0;
let $y = 0;
let $linestr = (;
while ($points)
{
let $linestr = $linestr $x $y,;
dec $points;
inc $x;
inc $y;
}
let $linestr = $linestr 9999 9999);
--eval INSERT INTO t1 VALUES (1, ST_linefromtext(concat('linestring', '$linestr')));
ALTER TABLE t1 ROW_FORMAT = DYNAMIC, KEY_BLOCK_SIZE=0, ALGORITHM=INPLACE;
DROP TABLE t1;
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