mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Bug#24630 Subselect query crashes mysqld
The crash happens because second filling of the same I_S table happens in case of subselect with order by. table->sort.io_cache previously allocated in create_sort_index() is deleted during second filling (function get_schema_tables_result). There are two places where I_S table can be filled: JOIN::exec and create_sort_index(). To fix the bug we should check if the table was already filled in one of these places and skip processing of the table in second.
This commit is contained in:
@ -1278,3 +1278,40 @@ table_name
|
||||
t1
|
||||
t2
|
||||
drop table t1,t2;
|
||||
select 1 as f1 from information_schema.tables where "CHARACTER_SETS"=
|
||||
(select cast(table_name as char) from information_schema.tables
|
||||
order by table_name limit 1) limit 1;
|
||||
f1
|
||||
1
|
||||
select t.table_name, group_concat(t.table_schema, '.', t.table_name),
|
||||
count(*) as num1
|
||||
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 isnull(c2.column_type) -
|
||||
isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
|
||||
count(*) as num
|
||||
from information_schema.columns c2 where
|
||||
c2.table_schema='information_schema' and
|
||||
(c2.column_type = 'varchar(7)' or c2.column_type = 'varchar(20)')
|
||||
group by c2.column_type order by num limit 1)
|
||||
group by t.table_name order by num1, t.table_name;
|
||||
table_name group_concat(t.table_schema, '.', t.table_name) num1
|
||||
CHARACTER_SETS information_schema.CHARACTER_SETS 1
|
||||
COLLATIONS information_schema.COLLATIONS 1
|
||||
COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
|
||||
COLUMNS information_schema.COLUMNS 1
|
||||
COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
|
||||
KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
|
||||
ROUTINES information_schema.ROUTINES 1
|
||||
SCHEMATA information_schema.SCHEMATA 1
|
||||
SCHEMA_PRIVILEGES information_schema.SCHEMA_PRIVILEGES 1
|
||||
STATISTICS information_schema.STATISTICS 1
|
||||
TABLES information_schema.TABLES 1
|
||||
TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
|
||||
TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
|
||||
TRIGGERS information_schema.TRIGGERS 1
|
||||
USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
|
||||
VIEWS information_schema.VIEWS 1
|
||||
|
@ -999,4 +999,28 @@ where table_schema = 'test' and table_name not in
|
||||
where table_schema = 'test' and column_name = 'f3');
|
||||
drop table t1,t2;
|
||||
|
||||
|
||||
#
|
||||
# Bug#24630 Subselect query crashes mysqld
|
||||
#
|
||||
select 1 as f1 from information_schema.tables where "CHARACTER_SETS"=
|
||||
(select cast(table_name as char) from information_schema.tables
|
||||
order by table_name limit 1) limit 1;
|
||||
|
||||
select t.table_name, group_concat(t.table_schema, '.', t.table_name),
|
||||
count(*) as num1
|
||||
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 isnull(c2.column_type) -
|
||||
isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
|
||||
count(*) as num
|
||||
from information_schema.columns c2 where
|
||||
c2.table_schema='information_schema' and
|
||||
(c2.column_type = 'varchar(7)' or c2.column_type = 'varchar(20)')
|
||||
group by c2.column_type order by num limit 1)
|
||||
group by t.table_name order by num1, t.table_name;
|
||||
|
||||
# End of 5.0 tests.
|
||||
|
Reference in New Issue
Block a user