1DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
2DROP VIEW IF EXISTS v1;
3#
4# Bug#18925: subqueries with MIN/MAX functions on INFORMARTION_SCHEMA
5#
6SELECT t.table_name, c1.column_name
7FROM information_schema.tables t
8INNER JOIN
9information_schema.columns c1
10ON t.table_schema = c1.table_schema AND
11t.table_name = c1.table_name
12WHERE t.table_schema = 'information_schema' AND
13c1.ordinal_position =
14( SELECT COALESCE(MIN(c2.ordinal_position),1)
15FROM information_schema.columns c2
16WHERE c2.table_schema = t.table_schema AND
17c2.table_name = t.table_name AND
18c2.column_name LIKE '%SCHEMA%'
19        )
20AND t.table_name NOT LIKE 'ndb%'
21  AND t.table_name NOT LIKE 'innodb%';
22table_name	column_name
23CHARACTER_SETS	CHARACTER_SET_NAME
24CLIENT_STATISTICS	CLIENT
25COLLATIONS	COLLATION_NAME
26COLLATION_CHARACTER_SET_APPLICABILITY	COLLATION_NAME
27COLUMNS	TABLE_SCHEMA
28COLUMN_PRIVILEGES	TABLE_SCHEMA
29INDEX_STATISTICS	TABLE_SCHEMA
30ENGINES	ENGINE
31EVENTS	EVENT_SCHEMA
32FILES	TABLE_SCHEMA
33GLOBAL_STATUS	VARIABLE_NAME
34GLOBAL_TEMPORARY_TABLES	TABLE_SCHEMA
35GLOBAL_VARIABLES	VARIABLE_NAME
36KEY_COLUMN_USAGE	CONSTRAINT_SCHEMA
37OPTIMIZER_TRACE	QUERY
38PARAMETERS	SPECIFIC_SCHEMA
39PARTITIONS	TABLE_SCHEMA
40PLUGINS	PLUGIN_NAME
41PROCESSLIST	ID
42PROFILING	QUERY_ID
43REFERENTIAL_CONSTRAINTS	CONSTRAINT_SCHEMA
44ROUTINES	ROUTINE_SCHEMA
45SCHEMATA	SCHEMA_NAME
46SCHEMA_PRIVILEGES	TABLE_SCHEMA
47SESSION_STATUS	VARIABLE_NAME
48SESSION_VARIABLES	VARIABLE_NAME
49STATISTICS	TABLE_SCHEMA
50TABLES	TABLE_SCHEMA
51TABLESPACES	TABLESPACE_NAME
52TABLE_CONSTRAINTS	CONSTRAINT_SCHEMA
53TABLE_PRIVILEGES	TABLE_SCHEMA
54TABLE_STATISTICS	TABLE_SCHEMA
55TEMPORARY_TABLES	TABLE_SCHEMA
56THREAD_STATISTICS	THREAD_ID
57TRIGGERS	TRIGGER_SCHEMA
58USER_PRIVILEGES	GRANTEE
59USER_STATISTICS	USER
60VIEWS	TABLE_SCHEMA
61XTRADB_READ_VIEW	READ_VIEW_LOW_LIMIT_TRX_NUMBER
62XTRADB_RSEG	rseg_id
63XTRADB_INTERNAL_HASH_TABLES	INTERNAL_HASH_TABLE_NAME
64XTRADB_ZIP_DICT	id
65XTRADB_ZIP_DICT_COLS	table_id
66SELECT t.table_name, c1.column_name
67FROM information_schema.tables t
68INNER JOIN
69information_schema.columns c1
70ON t.table_schema = c1.table_schema AND
71t.table_name = c1.table_name
72WHERE t.table_schema = 'information_schema' AND
73c1.ordinal_position =
74( SELECT COALESCE(MIN(c2.ordinal_position),1)
75FROM information_schema.columns c2
76WHERE c2.table_schema = 'information_schema' AND
77c2.table_name = t.table_name AND
78c2.column_name LIKE '%SCHEMA%'
79        )
80AND t.table_name NOT LIKE 'ndb%'
81  AND t.table_name NOT LIKE 'innodb%';
82table_name	column_name
83CHARACTER_SETS	CHARACTER_SET_NAME
84CLIENT_STATISTICS	CLIENT
85COLLATIONS	COLLATION_NAME
86COLLATION_CHARACTER_SET_APPLICABILITY	COLLATION_NAME
87COLUMNS	TABLE_SCHEMA
88COLUMN_PRIVILEGES	TABLE_SCHEMA
89INDEX_STATISTICS	TABLE_SCHEMA
90ENGINES	ENGINE
91EVENTS	EVENT_SCHEMA
92FILES	TABLE_SCHEMA
93GLOBAL_STATUS	VARIABLE_NAME
94GLOBAL_TEMPORARY_TABLES	TABLE_SCHEMA
95GLOBAL_VARIABLES	VARIABLE_NAME
96KEY_COLUMN_USAGE	CONSTRAINT_SCHEMA
97OPTIMIZER_TRACE	QUERY
98PARAMETERS	SPECIFIC_SCHEMA
99PARTITIONS	TABLE_SCHEMA
100PLUGINS	PLUGIN_NAME
101PROCESSLIST	ID
102PROFILING	QUERY_ID
103REFERENTIAL_CONSTRAINTS	CONSTRAINT_SCHEMA
104ROUTINES	ROUTINE_SCHEMA
105SCHEMATA	SCHEMA_NAME
106SCHEMA_PRIVILEGES	TABLE_SCHEMA
107SESSION_STATUS	VARIABLE_NAME
108SESSION_VARIABLES	VARIABLE_NAME
109STATISTICS	TABLE_SCHEMA
110TABLES	TABLE_SCHEMA
111TABLESPACES	TABLESPACE_NAME
112TABLE_CONSTRAINTS	CONSTRAINT_SCHEMA
113TABLE_PRIVILEGES	TABLE_SCHEMA
114TABLE_STATISTICS	TABLE_SCHEMA
115TEMPORARY_TABLES	TABLE_SCHEMA
116THREAD_STATISTICS	THREAD_ID
117TRIGGERS	TRIGGER_SCHEMA
118USER_PRIVILEGES	GRANTEE
119USER_STATISTICS	USER
120VIEWS	TABLE_SCHEMA
121XTRADB_READ_VIEW	READ_VIEW_LOW_LIMIT_TRX_NUMBER
122XTRADB_RSEG	rseg_id
123XTRADB_INTERNAL_HASH_TABLES	INTERNAL_HASH_TABLE_NAME
124XTRADB_ZIP_DICT	id
125XTRADB_ZIP_DICT_COLS	table_id
126