Skip to content

Commit c1eaa38

Browse files
committed
MDEV-21616: Server crash when using "SET STATEMENT max_statement_time=0 FOR desc xxx" lead to collapse
Main select should be pushed first.
1 parent 2acc6f2 commit c1eaa38

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

mysql-test/main/parser.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,4 +1797,14 @@ select * from t2;
17971797
ERROR HY000: Table 't2' was not locked with LOCK TABLES
17981798
SET STATEMENT max_statement_time=900 FOR unlock tables;
17991799
drop table t1, t2;
1800+
#
1801+
# MDEV-21616: Server crash when using
1802+
# "SET STATEMENT max_statement_time=0 FOR desc xxx" lead to collapse
1803+
#
1804+
create table t1 (a int);
1805+
SET STATEMENT max_statement_time=0 FOR desc t1;
1806+
Field Type Null Key Default Extra
1807+
a int(11) YES NULL
1808+
drop table t1;
1809+
SET STATEMENT max_statement_time=0 FOR do 1;
18001810
# End of 10.4 tests

mysql-test/main/parser.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,4 +1565,14 @@ select * from t2;
15651565
SET STATEMENT max_statement_time=900 FOR unlock tables;
15661566
drop table t1, t2;
15671567

1568+
--echo #
1569+
--echo # MDEV-21616: Server crash when using
1570+
--echo # "SET STATEMENT max_statement_time=0 FOR desc xxx" lead to collapse
1571+
--echo #
1572+
1573+
create table t1 (a int);
1574+
SET STATEMENT max_statement_time=0 FOR desc t1;
1575+
drop table t1;
1576+
SET STATEMENT max_statement_time=0 FOR do 1;
1577+
15681578
--echo # End of 10.4 tests

sql/sql_yacc.yy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13253,11 +13253,14 @@ do:
1325313253
{
1325413254
LEX *lex=Lex;
1325513255
lex->sql_command = SQLCOM_DO;
13256+
if (lex->main_select_push())
13257+
MYSQL_YYABORT;
1325613258
mysql_init_select(lex);
1325713259
}
1325813260
expr_list
1325913261
{
1326013262
Lex->insert_list= $3;
13263+
Lex->pop_select(); //main select
1326113264
}
1326213265
;
1326313266

@@ -14552,6 +14555,8 @@ describe:
1455214555
describe_command table_ident
1455314556
{
1455414557
LEX *lex= Lex;
14558+
if (lex->main_select_push())
14559+
MYSQL_YYABORT;
1455514560
mysql_init_select(lex);
1455614561
lex->current_select->parsing_place= SELECT_LIST;
1455714562
lex->sql_command= SQLCOM_SHOW_FIELDS;
@@ -14563,6 +14568,7 @@ describe:
1456314568
opt_describe_column
1456414569
{
1456514570
Select->parsing_place= NO_MATTER;
14571+
Lex->pop_select(); //main select
1456614572
}
1456714573
| describe_command opt_extended_describe
1456814574
{ Lex->describe|= DESCRIBE_NORMAL; }

0 commit comments

Comments
 (0)