Skip to content

Commit f858083

Browse files
author
Sergey Glukhov
committed
Bug#26877788 SELECT FROM INFORMATION_SCHEMA.FILES RETURNS NO RECORDS WHEN ORDER BY IS USED
During subquery materialization table list is modified so that empty JOIN_TAB table is inserted in the middle of table list. It leads to interruption of the loop in get_schema_tables_result() function and tables which are after empty JOIN_TAB are not processed. The fix: Do not interrupt the loop on empty JOIN_TAB.
1 parent f7cc223 commit f858083

File tree

3 files changed

+66
-2
lines changed

3 files changed

+66
-2
lines changed

mysql-test/r/information_schema.result

+36
Original file line numberDiff line numberDiff line change
@@ -2114,5 +2114,41 @@ DROP TABLE t1;
21142114
CREATE PROCEDURE information_schema.is() BEGIN END;
21152115
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
21162116
#
2117+
# Bug#26877788 SELECT FROM INFORMATION_SCHEMA.FILES RETURNS NO RECORDS WHEN ORDER BY IS USED
2118+
#
2119+
EXPLAIN SELECT ENGINE, SUPPORT, TRANSACTIONS FROM INFORMATION_SCHEMA.ENGINES
2120+
WHERE
2121+
SUPPORT IN (
2122+
SELECT DISTINCT SUPPORT
2123+
FROM INFORMATION_SCHEMA.ENGINES
2124+
WHERE
2125+
ENGINE IN (
2126+
SELECT DISTINCT ENGINE FROM INFORMATION_SCHEMA.ENGINES
2127+
WHERE ENGINE IN ('MEMORY')))
2128+
ORDER BY ENGINE;
2129+
id select_type table type possible_keys key key_len ref rows Extra
2130+
1 SIMPLE ENGINES ALL NULL NULL NULL NULL NULL Using where; Using filesort
2131+
1 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 26 information_schema.ENGINES.SUPPORT 1 NULL
2132+
2 MATERIALIZED ENGINES ALL NULL NULL NULL NULL NULL Using where
2133+
2 MATERIALIZED ENGINES ALL NULL NULL NULL NULL NULL Using where; Using join buffer (Block Nested Loop)
2134+
SELECT ENGINE, SUPPORT, TRANSACTIONS FROM INFORMATION_SCHEMA.ENGINES
2135+
WHERE
2136+
SUPPORT IN (
2137+
SELECT DISTINCT SUPPORT
2138+
FROM INFORMATION_SCHEMA.ENGINES
2139+
WHERE
2140+
ENGINE IN (
2141+
SELECT DISTINCT ENGINE FROM INFORMATION_SCHEMA.ENGINES
2142+
WHERE ENGINE IN ('MEMORY')))
2143+
ORDER BY ENGINE;
2144+
ENGINE SUPPORT TRANSACTIONS
2145+
ARCHIVE YES NO
2146+
BLACKHOLE YES NO
2147+
CSV YES NO
2148+
InnoDB YES YES
2149+
MEMORY YES NO
2150+
MRG_MYISAM YES NO
2151+
PERFORMANCE_SCHEMA YES NO
2152+
#
21172153
# End of 5.6 tests
21182154
#

mysql-test/t/information_schema.test

+28
Original file line numberDiff line numberDiff line change
@@ -1878,6 +1878,34 @@ DROP TABLE t1;
18781878
--error ER_DBACCESS_DENIED_ERROR
18791879
CREATE PROCEDURE information_schema.is() BEGIN END;
18801880

1881+
1882+
--echo #
1883+
--echo # Bug#26877788 SELECT FROM INFORMATION_SCHEMA.FILES RETURNS NO RECORDS WHEN ORDER BY IS USED
1884+
--echo #
1885+
1886+
EXPLAIN SELECT ENGINE, SUPPORT, TRANSACTIONS FROM INFORMATION_SCHEMA.ENGINES
1887+
WHERE
1888+
SUPPORT IN (
1889+
SELECT DISTINCT SUPPORT
1890+
FROM INFORMATION_SCHEMA.ENGINES
1891+
WHERE
1892+
ENGINE IN (
1893+
SELECT DISTINCT ENGINE FROM INFORMATION_SCHEMA.ENGINES
1894+
WHERE ENGINE IN ('MEMORY')))
1895+
ORDER BY ENGINE;
1896+
1897+
SELECT ENGINE, SUPPORT, TRANSACTIONS FROM INFORMATION_SCHEMA.ENGINES
1898+
WHERE
1899+
SUPPORT IN (
1900+
SELECT DISTINCT SUPPORT
1901+
FROM INFORMATION_SCHEMA.ENGINES
1902+
WHERE
1903+
ENGINE IN (
1904+
SELECT DISTINCT ENGINE FROM INFORMATION_SCHEMA.ENGINES
1905+
WHERE ENGINE IN ('MEMORY')))
1906+
ORDER BY ENGINE;
1907+
1908+
18811909
--echo #
18821910
--echo # End of 5.6 tests
18831911
--echo #

sql/sql_show.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -7484,7 +7484,7 @@ bool get_schema_tables_result(JOIN *join,
74847484
{
74857485
JOIN_TAB *const tab= join->join_tab + i;
74867486
if (!tab->table || !tab->table->pos_in_table_list)
7487-
break;
7487+
continue;
74887488

74897489
TABLE_LIST *table_list= tab->table->pos_in_table_list;
74907490
if (table_list->schema_table && thd->fill_information_schema_tables())

0 commit comments

Comments
 (0)