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

MDEV-13625: Adapt the test innodb-system-table-view

parent 5a22c456
--echo === information_schema.innodb_sys_tables and innodb_sys_tablespaces ===
--disable_query_log
--replace_result #P# #p# #SP# #sp#
--replace_regex /FTS_([0-9a-f_]+)([A-Z0-9_]+)/FTS_AUX_\2/
SELECT t.name 'Table Name',
s.name 'Tablespace',
t.flag 'Table Flags',
t.n_cols 'Columns',
t.row_format 'Row Format',
t.zip_page_size 'Zip Size'
FROM information_schema.innodb_sys_tables t LEFT JOIN
information_schema.innodb_sys_tablespaces s
ON t.space = s.space
WHERE t.name not like 'SYS_%'
AND t.name NOT LIKE 'mysql/%'
AND t.name NOT LIKE 'sys/%'
ORDER BY t.name;
--enable_query_log
# This script assumes that the caller did the following;
# LET $MYSQLD_DATADIR = `select @@datadir`;
# LET $INNODB_PAGE_SIZE = `select @@innodb_page_size`;
--echo === information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
--disable_query_log
--replace_regex /#P#/#p#/ /#SP#/#sp#/
--replace_result ./ MYSQLD_DATADIR/ $MYSQLD_DATADIR/ MYSQLD_DATADIR/ $MYSQLD_DATADIR MYSQLD_DATADIR/ $MYSQL_TMP_DIR MYSQL_TMP_DIR $INNODB_PAGE_SIZE DEFAULT
SELECT s.name 'Space_Name',
s.page_size 'Page_Size',
s.zip_page_size 'Zip_Size',
s.row_format 'Formats_Permitted',
d.path 'Path'
FROM information_schema.innodb_sys_tablespaces s,
information_schema.innodb_sys_datafiles d
WHERE s.space = d.space
AND s.name NOT LIKE 'mysql/%'
AND s.name NOT LIKE 'sys/%'
ORDER BY s.space;
--enable_query_log
SELECT table_id INTO @table_stats_id FROM information_schema.innodb_sys_tables
WHERE name = 'mysql/innodb_table_stats';
SELECT table_id INTO @index_stats_id FROM information_schema.innodb_sys_tables
WHERE name = 'mysql/innodb_index_stats';
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE table_id NOT IN (@table_stats_id, @index_stats_id) ORDER BY table_id;
TABLE_ID NAME FLAG N_COLS SPACE FILE_FORMAT ROW_FORMAT ZIP_PAGE_SIZE
11 SYS_FOREIGN 0 7 0 Antelope Redundant 0
12 SYS_FOREIGN_COLS 0 7 0 Antelope Redundant 0
13 SYS_TABLESPACES 0 6 0 Antelope Redundant 0
14 SYS_DATAFILES 0 5 0 Antelope Redundant 0
SELECT table_id,pos,mtype,prtype,len,name
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS
WHERE table_id NOT IN (@table_stats_id, @index_stats_id)
ORDER BY table_id, pos;
table_id pos mtype prtype len name
11 0 1 524292 0 ID
11 1 1 524292 0 FOR_NAME
11 2 1 524292 0 REF_NAME
11 3 6 0 4 N_COLS
12 0 1 524292 0 ID
12 1 6 0 4 POS
12 2 1 524292 0 FOR_COL_NAME
12 3 1 524292 0 REF_COL_NAME
13 0 6 0 4 SPACE
13 1 1 524292 0 NAME
13 2 6 0 4 FLAGS
14 0 6 0 4 SPACE
14 1 1 524292 0 PATH
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES
WHERE table_id NOT IN (@table_stats_id, @index_stats_id) ORDER BY index_id;
INDEX_ID NAME TABLE_ID TYPE N_FIELDS PAGE_NO SPACE
# ID_IND # 3 1 # #
# FOR_IND # 0 1 # #
# REF_IND # 0 1 # #
# ID_IND # 3 2 # #
# SYS_TABLESPACES_SPACE # 3 1 # #
# SYS_DATAFILES_SPACE # 3 1 # #
SELECT index_id,pos,name FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS
WHERE name NOT IN ('database_name', 'table_name', 'index_name', 'stat_name')
ORDER BY index_id, pos;
index_id pos name
11 0 ID
12 0 FOR_NAME
13 0 REF_NAME
14 0 ID
14 1 POS
15 0 SPACE
16 0 SPACE
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
CREATE TABLE t_redundant (a INT KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=innodb;
CREATE TABLE t_compact (a INT KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=innodb;
CREATE TABLE t_compressed (a INT KEY, b TEXT) ROW_FORMAT=COMPRESSED ENGINE=innodb KEY_BLOCK_SIZE=2;
CREATE TABLE t_dynamic (a INT KEY, b TEXT) ROW_FORMAT=DYNAMIC ENGINE=innodb;
=== information_schema.innodb_sys_tables and innodb_sys_tablespaces ===
Table Name Tablespace Table Flags Columns Row Format Zip Size
test/t_compact test/t_compact 1 5 Compact 0
test/t_compressed test/t_compressed 37 5 Compressed 2048
test/t_dynamic test/t_dynamic 33 5 Dynamic 0
test/t_redundant test/t_redundant 0 5 Redundant 0
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
Space_Name Page_Size Zip_Size Formats_Permitted Path
test/t_redundant DEFAULT 0 Compact or Redundant MYSQLD_DATADIR/test/t_redundant.ibd
test/t_compact DEFAULT 0 Compact or Redundant MYSQLD_DATADIR/test/t_compact.ibd
test/t_compressed DEFAULT 2048 Compressed MYSQLD_DATADIR/test/t_compressed.ibd
test/t_dynamic DEFAULT 0 Dynamic MYSQLD_DATADIR/test/t_dynamic.ibd
DROP TABLE t_redundant, t_compact, t_compressed, t_dynamic;
SELECT count(*) FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS;
count(*)
6
CREATE TABLE parent (id INT NOT NULL,
PRIMARY KEY (id)) ENGINE=INNODB;
CREATE TABLE child (id INT, parent_id INT,
INDEX par_ind (parent_id),
CONSTRAINT constraint_test
FOREIGN KEY (parent_id) REFERENCES parent(id)
ON DELETE CASCADE) ENGINE=INNODB;
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/constraint_test test/child test/parent 1 1
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
test/constraint_test parent_id id 0
INSERT INTO parent VALUES(1);
SELECT name, num_rows, ref_count
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name LIKE "%parent";
name num_rows ref_count
test/parent 1 1
SELECT NAME, FLAG, N_COLS FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name NOT LIKE 'sys/%';
NAME FLAG N_COLS
SYS_DATAFILES 0 5
SYS_FOREIGN 0 7
SYS_FOREIGN_COLS 0 7
SYS_TABLESPACES 0 6
mysql/innodb_index_stats 1 11
mysql/innodb_table_stats 1 9
test/child 1 5
test/parent 1 4
SELECT name, n_fields
from INFORMATION_SCHEMA.INNODB_SYS_INDEXES
WHERE table_id In (SELECT table_id from
INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE "%parent%");
name n_fields
PRIMARY 1
SELECT name, n_fields
from INFORMATION_SCHEMA.INNODB_SYS_INDEXES
WHERE table_id In (SELECT table_id from
INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE "%child%");
name n_fields
GEN_CLUST_INDEX 0
par_ind 1
SELECT name, pos, mtype, len
from INFORMATION_SCHEMA.INNODB_SYS_COLUMNS
WHERE table_id In (SELECT table_id from
INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE "%child%");
name pos mtype len
id 0 6 4
parent_id 1 6 4
DROP TABLE child;
DROP TABLE parent;
CREATE TABLE parent (id INT NOT NULL, newid INT NOT NULL,
PRIMARY KEY (id, newid)) ENGINE=INNODB;
CREATE TABLE child (id INT, parent_id INT,
INDEX par_ind (parent_id),
CONSTRAINT constraint_test
FOREIGN KEY (id, parent_id) REFERENCES parent(id, newid)
ON DELETE CASCADE) ENGINE=INNODB;
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
ID FOR_NAME REF_NAME N_COLS TYPE
test/constraint_test test/child test/parent 2 1
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
ID FOR_COL_NAME REF_COL_NAME POS
test/constraint_test id id 0
test/constraint_test parent_id newid 1
INSERT INTO parent VALUES(1, 9);
SELECT * FROM parent WHERE id IN (SELECT id FROM parent);
id newid
1 9
SELECT name, num_rows, ref_count
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name LIKE "%parent";
name num_rows ref_count
test/parent 1 2
DROP TABLE child;
DROP TABLE parent;
--innodb
--innodb-sys-tablespaces
--innodb-sys-datafiles
--innodb-sys-tablestats
--innodb-sys-tables
--innodb-sys-columns
--innodb-sys-indexes
--innodb-sys-fields
--innodb-sys-foreign
--innodb-sys-foreign-cols
--innodb-file-format=barracuda
# This is the test for Information Schema System Table View
# that displays the InnoDB system table content through
# information schema tables.
--source include/innodb_page_size_small.inc
--disable_query_log
SET default_storage_engine=InnoDB;
LET $MYSQLD_DATADIR = `select @@datadir`;
LET $INNODB_PAGE_SIZE = `select @@innodb_page_size`;
--enable_query_log
# The IDs of mysql.innodb_table_stats and mysql.innodb_index_stats may
# vary depending on whether the tables have been rebuilt
# by previously run tests.
SELECT table_id INTO @table_stats_id FROM information_schema.innodb_sys_tables
WHERE name = 'mysql/innodb_table_stats';
SELECT table_id INTO @index_stats_id FROM information_schema.innodb_sys_tables
WHERE name = 'mysql/innodb_index_stats';
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE table_id NOT IN (@table_stats_id, @index_stats_id) ORDER BY table_id;
SELECT table_id,pos,mtype,prtype,len,name
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS
WHERE table_id NOT IN (@table_stats_id, @index_stats_id)
ORDER BY table_id, pos;
--replace_column 1 # 3 # 6 # 7 #
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES
WHERE table_id NOT IN (@table_stats_id, @index_stats_id) ORDER BY index_id;
SELECT index_id,pos,name FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS
WHERE name NOT IN ('database_name', 'table_name', 'index_name', 'stat_name')
ORDER BY index_id, pos;
--sorted_result
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
--sorted_result
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
CREATE TABLE t_redundant (a INT KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=innodb;
CREATE TABLE t_compact (a INT KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=innodb;
CREATE TABLE t_compressed (a INT KEY, b TEXT) ROW_FORMAT=COMPRESSED ENGINE=innodb KEY_BLOCK_SIZE=2;
CREATE TABLE t_dynamic (a INT KEY, b TEXT) ROW_FORMAT=DYNAMIC ENGINE=innodb;
--source suite/innodb/include/show_i_s_tables.inc
--source suite/innodb/include/show_i_s_tablespaces.inc
DROP TABLE t_redundant, t_compact, t_compressed, t_dynamic;
SELECT count(*) FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS;
# Create a foreign key constraint, and verify the information
# in INFORMATION_SCHEMA.INNODB_SYS_FOREIGN and
# INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS
CREATE TABLE parent (id INT NOT NULL,
PRIMARY KEY (id)) ENGINE=INNODB;
CREATE TABLE child (id INT, parent_id INT,
INDEX par_ind (parent_id),
CONSTRAINT constraint_test
FOREIGN KEY (parent_id) REFERENCES parent(id)
ON DELETE CASCADE) ENGINE=INNODB;
--sorted_result
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
--sorted_result
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
# Insert a row in the table "parent", and see whether that reflected in
# INNODB_SYS_TABLESTATS
INSERT INTO parent VALUES(1);
--sorted_result
SELECT name, num_rows, ref_count
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name LIKE "%parent";
--sorted_result
SELECT NAME, FLAG, N_COLS FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name NOT LIKE 'sys/%';
--sorted_result
SELECT name, n_fields
from INFORMATION_SCHEMA.INNODB_SYS_INDEXES
WHERE table_id In (SELECT table_id from
INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE "%parent%");
--sorted_result
SELECT name, n_fields
from INFORMATION_SCHEMA.INNODB_SYS_INDEXES
WHERE table_id In (SELECT table_id from
INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE "%child%");
--sorted_result
SELECT name, pos, mtype, len
from INFORMATION_SCHEMA.INNODB_SYS_COLUMNS
WHERE table_id In (SELECT table_id from
INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE "%child%");
DROP TABLE child;
DROP TABLE parent;
# Create table with 2 columns in the foreign key constraint
CREATE TABLE parent (id INT NOT NULL, newid INT NOT NULL,
PRIMARY KEY (id, newid)) ENGINE=INNODB;
CREATE TABLE child (id INT, parent_id INT,
INDEX par_ind (parent_id),
CONSTRAINT constraint_test
FOREIGN KEY (id, parent_id) REFERENCES parent(id, newid)
ON DELETE CASCADE) ENGINE=INNODB;
--sorted_result
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN;
--sorted_result
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
INSERT INTO parent VALUES(1, 9);
# Nested query will open the table handle twice
--sorted_result
SELECT * FROM parent WHERE id IN (SELECT id FROM parent);
--sorted_result
SELECT name, num_rows, ref_count
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name LIKE "%parent";
DROP TABLE child;
DROP TABLE parent;
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