# This is the test for Information Schema System Table View # that displays the InnoDB system table content through # information schema tables. --source include/have_innodb.inc SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; SELECT * 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; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; 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); SELECT name, num_rows, mysql_handles_opened FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS WHERE name LIKE "%parent"; SELECT NAME, FLAG, N_COLS, SPACE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES; 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%"); 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%"); 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; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS; INSERT INTO parent VALUES(1, 9); # Nested query will open the table handle twice SELECT * FROM parent WHERE id IN (SELECT id FROM parent); SELECT name, num_rows, mysql_handles_opened FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS WHERE name LIKE "%parent"; DROP TABLE child; DROP TABLE parent;