From 843b73b34babef027d093473a181cba440cb3cd0 Mon Sep 17 00:00:00 2001
From: Guilhem Bichot <guilhem@mysql.com>
Date: Mon, 5 Oct 2009 16:22:48 +0200
Subject: [PATCH] Port of fix for BUG#42893 "main.information_schema times out
 sporadically" (from revision
 konstantin@mysql.com-20080627154042-923m6lzk7z77lrgj ). This moves the slow
 part (10 seconds over 13) into a separate big test.

---
 mysql-test/r/information_schema-big.result | 93 ++++++++++++++++++++++
 mysql-test/r/information_schema.result     | 88 --------------------
 mysql-test/t/information_schema-big.test   | 48 +++++++++++
 mysql-test/t/information_schema.test       | 35 --------
 4 files changed, 141 insertions(+), 123 deletions(-)
 create mode 100644 mysql-test/r/information_schema-big.result
 create mode 100644 mysql-test/t/information_schema-big.test

diff --git a/mysql-test/r/information_schema-big.result b/mysql-test/r/information_schema-big.result
new file mode 100644
index 0000000000..248b8d606d
--- /dev/null
+++ b/mysql-test/r/information_schema-big.result
@@ -0,0 +1,93 @@
+DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
+DROP VIEW IF EXISTS v1;
+#
+# Bug#18925: subqueries with MIN/MAX functions on INFORMARTION_SCHEMA 
+#
+SELECT t.table_name, c1.column_name
+FROM information_schema.tables t
+INNER JOIN
+information_schema.columns c1
+ON t.table_schema = c1.table_schema AND
+t.table_name = c1.table_name
+WHERE t.table_schema = 'information_schema' AND
+c1.ordinal_position =
+( SELECT COALESCE(MIN(c2.ordinal_position),1)
+FROM information_schema.columns c2
+WHERE c2.table_schema = t.table_schema AND
+c2.table_name = t.table_name AND
+c2.column_name LIKE '%SCHEMA%'
+        )
+AND t.table_name NOT LIKE 'innodb%';
+table_name	column_name
+CHARACTER_SETS	CHARACTER_SET_NAME
+COLLATIONS	COLLATION_NAME
+COLLATION_CHARACTER_SET_APPLICABILITY	COLLATION_NAME
+COLUMNS	TABLE_SCHEMA
+COLUMN_PRIVILEGES	TABLE_SCHEMA
+ENGINES	ENGINE
+EVENTS	EVENT_SCHEMA
+FILES	TABLE_SCHEMA
+GLOBAL_STATUS	VARIABLE_NAME
+GLOBAL_VARIABLES	VARIABLE_NAME
+KEY_COLUMN_USAGE	CONSTRAINT_SCHEMA
+PARTITIONS	TABLE_SCHEMA
+PLUGINS	PLUGIN_NAME
+PROCESSLIST	ID
+PROFILING	QUERY_ID
+REFERENTIAL_CONSTRAINTS	CONSTRAINT_SCHEMA
+ROUTINES	ROUTINE_SCHEMA
+SCHEMATA	SCHEMA_NAME
+SCHEMA_PRIVILEGES	TABLE_SCHEMA
+SESSION_STATUS	VARIABLE_NAME
+SESSION_VARIABLES	VARIABLE_NAME
+STATISTICS	TABLE_SCHEMA
+TABLES	TABLE_SCHEMA
+TABLE_CONSTRAINTS	CONSTRAINT_SCHEMA
+TABLE_PRIVILEGES	TABLE_SCHEMA
+TRIGGERS	TRIGGER_SCHEMA
+USER_PRIVILEGES	GRANTEE
+VIEWS	TABLE_SCHEMA
+SELECT t.table_name, c1.column_name
+FROM information_schema.tables t
+INNER JOIN
+information_schema.columns c1
+ON t.table_schema = c1.table_schema AND
+t.table_name = c1.table_name
+WHERE t.table_schema = 'information_schema' AND
+c1.ordinal_position =
+( SELECT COALESCE(MIN(c2.ordinal_position),1)
+FROM information_schema.columns c2
+WHERE c2.table_schema = 'information_schema' AND
+c2.table_name = t.table_name AND
+c2.column_name LIKE '%SCHEMA%'
+        )
+AND t.table_name NOT LIKE 'innodb%';
+table_name	column_name
+CHARACTER_SETS	CHARACTER_SET_NAME
+COLLATIONS	COLLATION_NAME
+COLLATION_CHARACTER_SET_APPLICABILITY	COLLATION_NAME
+COLUMNS	TABLE_SCHEMA
+COLUMN_PRIVILEGES	TABLE_SCHEMA
+ENGINES	ENGINE
+EVENTS	EVENT_SCHEMA
+FILES	TABLE_SCHEMA
+GLOBAL_STATUS	VARIABLE_NAME
+GLOBAL_VARIABLES	VARIABLE_NAME
+KEY_COLUMN_USAGE	CONSTRAINT_SCHEMA
+PARTITIONS	TABLE_SCHEMA
+PLUGINS	PLUGIN_NAME
+PROCESSLIST	ID
+PROFILING	QUERY_ID
+REFERENTIAL_CONSTRAINTS	CONSTRAINT_SCHEMA
+ROUTINES	ROUTINE_SCHEMA
+SCHEMATA	SCHEMA_NAME
+SCHEMA_PRIVILEGES	TABLE_SCHEMA
+SESSION_STATUS	VARIABLE_NAME
+SESSION_VARIABLES	VARIABLE_NAME
+STATISTICS	TABLE_SCHEMA
+TABLES	TABLE_SCHEMA
+TABLE_CONSTRAINTS	CONSTRAINT_SCHEMA
+TABLE_PRIVILEGES	TABLE_SCHEMA
+TRIGGERS	TRIGGER_SCHEMA
+USER_PRIVILEGES	GRANTEE
+VIEWS	TABLE_SCHEMA
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index ffa9b596d2..9a66c80922 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -1226,94 +1226,6 @@ f1()
 DROP FUNCTION f1;
 DROP PROCEDURE p1;
 DROP USER mysql_bug20230@localhost;
-SELECT t.table_name, c1.column_name
-FROM information_schema.tables t
-INNER JOIN
-information_schema.columns c1
-ON t.table_schema = c1.table_schema AND
-t.table_name = c1.table_name
-WHERE t.table_schema = 'information_schema' AND
-c1.ordinal_position =
-( SELECT COALESCE(MIN(c2.ordinal_position),1)
-FROM information_schema.columns c2
-WHERE c2.table_schema = t.table_schema AND
-c2.table_name = t.table_name AND
-c2.column_name LIKE '%SCHEMA%'
-        )
-AND t.table_name not like 'innodb_%';
-table_name	column_name
-CHARACTER_SETS	CHARACTER_SET_NAME
-COLLATIONS	COLLATION_NAME
-COLLATION_CHARACTER_SET_APPLICABILITY	COLLATION_NAME
-COLUMNS	TABLE_SCHEMA
-COLUMN_PRIVILEGES	TABLE_SCHEMA
-ENGINES	ENGINE
-EVENTS	EVENT_SCHEMA
-FILES	TABLE_SCHEMA
-GLOBAL_STATUS	VARIABLE_NAME
-GLOBAL_VARIABLES	VARIABLE_NAME
-KEY_COLUMN_USAGE	CONSTRAINT_SCHEMA
-PARTITIONS	TABLE_SCHEMA
-PLUGINS	PLUGIN_NAME
-PROCESSLIST	ID
-PROFILING	QUERY_ID
-REFERENTIAL_CONSTRAINTS	CONSTRAINT_SCHEMA
-ROUTINES	ROUTINE_SCHEMA
-SCHEMATA	SCHEMA_NAME
-SCHEMA_PRIVILEGES	TABLE_SCHEMA
-SESSION_STATUS	VARIABLE_NAME
-SESSION_VARIABLES	VARIABLE_NAME
-STATISTICS	TABLE_SCHEMA
-TABLES	TABLE_SCHEMA
-TABLE_CONSTRAINTS	CONSTRAINT_SCHEMA
-TABLE_PRIVILEGES	TABLE_SCHEMA
-TRIGGERS	TRIGGER_SCHEMA
-USER_PRIVILEGES	GRANTEE
-VIEWS	TABLE_SCHEMA
-SELECT t.table_name, c1.column_name
-FROM information_schema.tables t
-INNER JOIN
-information_schema.columns c1
-ON t.table_schema = c1.table_schema AND
-t.table_name = c1.table_name
-WHERE t.table_schema = 'information_schema' AND
-c1.ordinal_position =
-( SELECT COALESCE(MIN(c2.ordinal_position),1)
-FROM information_schema.columns c2
-WHERE c2.table_schema = 'information_schema' AND
-c2.table_name = t.table_name AND
-c2.column_name LIKE '%SCHEMA%'
-        )
-AND t.table_name not like 'innodb_%';
-table_name	column_name
-CHARACTER_SETS	CHARACTER_SET_NAME
-COLLATIONS	COLLATION_NAME
-COLLATION_CHARACTER_SET_APPLICABILITY	COLLATION_NAME
-COLUMNS	TABLE_SCHEMA
-COLUMN_PRIVILEGES	TABLE_SCHEMA
-ENGINES	ENGINE
-EVENTS	EVENT_SCHEMA
-FILES	TABLE_SCHEMA
-GLOBAL_STATUS	VARIABLE_NAME
-GLOBAL_VARIABLES	VARIABLE_NAME
-KEY_COLUMN_USAGE	CONSTRAINT_SCHEMA
-PARTITIONS	TABLE_SCHEMA
-PLUGINS	PLUGIN_NAME
-PROCESSLIST	ID
-PROFILING	QUERY_ID
-REFERENTIAL_CONSTRAINTS	CONSTRAINT_SCHEMA
-ROUTINES	ROUTINE_SCHEMA
-SCHEMATA	SCHEMA_NAME
-SCHEMA_PRIVILEGES	TABLE_SCHEMA
-SESSION_STATUS	VARIABLE_NAME
-SESSION_VARIABLES	VARIABLE_NAME
-STATISTICS	TABLE_SCHEMA
-TABLES	TABLE_SCHEMA
-TABLE_CONSTRAINTS	CONSTRAINT_SCHEMA
-TABLE_PRIVILEGES	TABLE_SCHEMA
-TRIGGERS	TRIGGER_SCHEMA
-USER_PRIVILEGES	GRANTEE
-VIEWS	TABLE_SCHEMA
 SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test');
 MAX(table_name)
 VIEWS
diff --git a/mysql-test/t/information_schema-big.test b/mysql-test/t/information_schema-big.test
new file mode 100644
index 0000000000..c9cd65f085
--- /dev/null
+++ b/mysql-test/t/information_schema-big.test
@@ -0,0 +1,48 @@
+# This test  uses grants, which can't get tested for embedded server
+-- source include/big_test.inc
+-- source include/not_embedded.inc
+
+# check that CSV engine was compiled in, as the result of the test depends
+# on the presence of the log tables (which are CSV-based).
+--source include/have_csv.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+
+
+--echo #
+--echo # Bug#18925: subqueries with MIN/MAX functions on INFORMARTION_SCHEMA 
+--echo #
+
+SELECT t.table_name, c1.column_name
+  FROM information_schema.tables t
+       INNER JOIN
+       information_schema.columns c1
+       ON t.table_schema = c1.table_schema AND
+          t.table_name = c1.table_name
+  WHERE t.table_schema = 'information_schema' AND
+        c1.ordinal_position =
+        ( SELECT COALESCE(MIN(c2.ordinal_position),1)
+            FROM information_schema.columns c2
+            WHERE c2.table_schema = t.table_schema AND
+                  c2.table_name = t.table_name AND
+                  c2.column_name LIKE '%SCHEMA%'
+        )
+  AND t.table_name NOT LIKE 'innodb%';
+SELECT t.table_name, c1.column_name
+  FROM information_schema.tables t
+       INNER JOIN
+       information_schema.columns c1
+       ON t.table_schema = c1.table_schema AND
+          t.table_name = c1.table_name
+  WHERE t.table_schema = 'information_schema' AND
+        c1.ordinal_position =
+        ( SELECT COALESCE(MIN(c2.ordinal_position),1)
+            FROM information_schema.columns c2
+            WHERE c2.table_schema = 'information_schema' AND
+                  c2.table_name = t.table_name AND
+                  c2.column_name LIKE '%SCHEMA%'
+        )
+  AND t.table_name NOT LIKE 'innodb%';
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index 6060c78f79..b590ec306d 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -913,41 +913,6 @@ DROP FUNCTION f1;
 DROP PROCEDURE p1;
 DROP USER mysql_bug20230@localhost;
 
-#
-# Bug#18925 subqueries with MIN/MAX functions on INFORMARTION_SCHEMA
-#
-
-SELECT t.table_name, c1.column_name
-  FROM information_schema.tables t
-       INNER JOIN
-       information_schema.columns c1
-       ON t.table_schema = c1.table_schema AND
-          t.table_name = c1.table_name
-  WHERE t.table_schema = 'information_schema' AND
-        c1.ordinal_position =
-        ( SELECT COALESCE(MIN(c2.ordinal_position),1)
-            FROM information_schema.columns c2
-            WHERE c2.table_schema = t.table_schema AND
-                  c2.table_name = t.table_name AND
-                  c2.column_name LIKE '%SCHEMA%'
-        )
-        AND t.table_name not like 'innodb_%';
-SELECT t.table_name, c1.column_name
-  FROM information_schema.tables t
-       INNER JOIN
-       information_schema.columns c1
-       ON t.table_schema = c1.table_schema AND
-          t.table_name = c1.table_name
-  WHERE t.table_schema = 'information_schema' AND
-        c1.ordinal_position =
-        ( SELECT COALESCE(MIN(c2.ordinal_position),1)
-            FROM information_schema.columns c2
-            WHERE c2.table_schema = 'information_schema' AND
-                  c2.table_name = t.table_name AND
-                  c2.column_name LIKE '%SCHEMA%'
-        )
-        AND t.table_name not like 'innodb_%';
-
 #
 # Bug#2123 query with a simple non-correlated subquery over
 #          INFORMARTION_SCHEMA.TABLES
-- 
2.30.9