summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2020-02-26 13:58:08 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2020-02-26 13:58:08 +0100
commita17a327f116302612a889af7c448ef1cd8243f28 (patch)
tree9909f1829b7b5fed53e76aa932456dc173d8e677
parente637355156cb28388a291b0e3a5e9ee863b2854d (diff)
downloadmariadb-git-a17a327f116302612a889af7c448ef1cd8243f28.tar.gz
MDEV-21684: mysqld crash with signal 11 when renaming table+max_statement_timebb-10.4-MDEV-21684
Main select should be pushed first in case of SET STATEMENT.
-rw-r--r--mysql-test/main/parser.result36
-rw-r--r--mysql-test/main/parser.test33
-rw-r--r--sql/sql_yacc.yy34
-rw-r--r--sql/sql_yacc_ora.yy40
4 files changed, 129 insertions, 14 deletions
diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result
index 868e3458368..d9f98ac3611 100644
--- a/mysql-test/main/parser.result
+++ b/mysql-test/main/parser.result
@@ -1807,4 +1807,40 @@ Field Type Null Key Default Extra
a int(11) YES NULL
drop table t1;
SET STATEMENT max_statement_time=0 FOR do 1;
+set @save_sql_mode=@@SQL_MODE;
+set SQL_MODE=ORACLE;
+create table t1 (a int);
+SET STATEMENT max_statement_time=0 FOR desc t1;
+Field Type Null Key Default Extra
+a int(11) YES NULL
+drop table t1;
+SET STATEMENT max_statement_time=0 FOR do 1;
+set SQL_MODE=@save_sql_mode;
+#
+# MDEV-21684: mysqld crash with signal 11 when renaming
+# table+max_statement_time
+#
+SET STATEMENT max_statement_time=180 FOR RENAME TABLE bleh TO blah;
+ERROR 42S02: Table 'test.bleh' doesn't exist
+SET STATEMENT max_statement_time=180 FOR load index into cache t1_base;
+Table Op Msg_type Msg_text
+test.t1_base preload_keys Error Table 'test.t1_base' doesn't exist
+test.t1_base preload_keys status Operation failed
+SET STATEMENT max_statement_time=180 FOR DROP INDEX i1 ON t1;
+ERROR 42S02: Table 'test.t1' doesn't exist
+SET STATEMENT max_statement_time=180 FOR BACKUP LOCK test.t1;
+SET STATEMENT max_statement_time=180 FOR BACKUP UNLOCK;
+set @save_sql_mode=@@SQL_MODE;
+set SQL_MODE=ORACLE;
+SET STATEMENT max_statement_time=180 FOR RENAME TABLE bleh TO blah;
+ERROR 42S02: Table 'test.bleh' doesn't exist
+SET STATEMENT max_statement_time=180 FOR load index into cache t1_base;
+Table Op Msg_type Msg_text
+test.t1_base preload_keys Error Table 'test.t1_base' doesn't exist
+test.t1_base preload_keys status Operation failed
+SET STATEMENT max_statement_time=180 FOR DROP INDEX i1 ON t1;
+ERROR 42S02: Table 'test.t1' doesn't exist
+SET STATEMENT max_statement_time=180 FOR BACKUP LOCK test.t1;
+SET STATEMENT max_statement_time=180 FOR BACKUP UNLOCK;
+set SQL_MODE=@save_sql_mode;
# End of 10.4 tests
diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test
index 54048d0de1d..dba155f1b7c 100644
--- a/mysql-test/main/parser.test
+++ b/mysql-test/main/parser.test
@@ -1575,4 +1575,37 @@ SET STATEMENT max_statement_time=0 FOR desc t1;
drop table t1;
SET STATEMENT max_statement_time=0 FOR do 1;
+set @save_sql_mode=@@SQL_MODE;
+set SQL_MODE=ORACLE;
+create table t1 (a int);
+SET STATEMENT max_statement_time=0 FOR desc t1;
+drop table t1;
+SET STATEMENT max_statement_time=0 FOR do 1;
+set SQL_MODE=@save_sql_mode;
+
+
+--echo #
+--echo # MDEV-21684: mysqld crash with signal 11 when renaming
+--echo # table+max_statement_time
+--echo #
+
+--error ER_NO_SUCH_TABLE
+SET STATEMENT max_statement_time=180 FOR RENAME TABLE bleh TO blah;
+SET STATEMENT max_statement_time=180 FOR load index into cache t1_base;
+--error ER_NO_SUCH_TABLE
+SET STATEMENT max_statement_time=180 FOR DROP INDEX i1 ON t1;
+SET STATEMENT max_statement_time=180 FOR BACKUP LOCK test.t1;
+SET STATEMENT max_statement_time=180 FOR BACKUP UNLOCK;
+
+set @save_sql_mode=@@SQL_MODE;
+set SQL_MODE=ORACLE;
+--error ER_NO_SUCH_TABLE
+SET STATEMENT max_statement_time=180 FOR RENAME TABLE bleh TO blah;
+SET STATEMENT max_statement_time=180 FOR load index into cache t1_base;
+--error ER_NO_SUCH_TABLE
+SET STATEMENT max_statement_time=180 FOR DROP INDEX i1 ON t1;
+SET STATEMENT max_statement_time=180 FOR BACKUP LOCK test.t1;
+SET STATEMENT max_statement_time=180 FOR BACKUP UNLOCK;
+set SQL_MODE=@save_sql_mode;
+
--echo # End of 10.4 tests
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index ed04d2a0584..f557d9cce92 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -8996,9 +8996,13 @@ rename:
RENAME table_or_tables
{
Lex->sql_command= SQLCOM_RENAME_TABLE;
+ if (Lex->main_select_push())
+ MYSQL_YYABORT;
}
table_to_table_list
- {}
+ {
+ Lex->pop_select(); //main select
+ }
| RENAME USER_SYM clear_privileges rename_list
{
Lex->sql_command = SQLCOM_RENAME_USER;
@@ -9096,9 +9100,13 @@ preload:
LEX *lex=Lex;
lex->sql_command=SQLCOM_PRELOAD_KEYS;
lex->alter_info.reset();
+ if (lex->main_select_push())
+ MYSQL_YYABORT;
}
preload_list_or_parts
- {}
+ {
+ Lex->pop_select(); //main select
+ }
;
preload_list_or_parts:
@@ -13278,11 +13286,16 @@ drop:
}
table_list opt_lock_wait_timeout opt_restrict
{}
- | DROP INDEX_SYM opt_if_exists_table_element ident ON table_ident opt_lock_wait_timeout
+ | DROP INDEX_SYM
+ {
+ if (Lex->main_select_push())
+ MYSQL_YYABORT;
+ }
+ opt_if_exists_table_element ident ON table_ident opt_lock_wait_timeout
{
LEX *lex=Lex;
Alter_drop *ad= (new (thd->mem_root)
- Alter_drop(Alter_drop::KEY, $4.str, $3));
+ Alter_drop(Alter_drop::KEY, $5.str, $4));
if (unlikely(ad == NULL))
MYSQL_YYABORT;
lex->sql_command= SQLCOM_DROP_INDEX;
@@ -13290,10 +13303,11 @@ drop:
lex->alter_info.flags= ALTER_DROP_INDEX;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
if (unlikely(!lex->current_select->
- add_table_to_list(thd, $6, NULL, TL_OPTION_UPDATING,
+ add_table_to_list(thd, $7, NULL, TL_OPTION_UPDATING,
TL_READ_NO_INSERT,
MDL_SHARED_UPGRADABLE)))
MYSQL_YYABORT;
+ Lex->pop_select(); //main select
}
| DROP DATABASE opt_if_exists ident
{
@@ -14789,12 +14803,18 @@ backup_statements:
Lex->backup_stage= (backup_stages) (type-1);
break;
}
- | LOCK_SYM table_ident
+ | LOCK_SYM
{
- if (unlikely(!Select->add_table_to_list(thd, $2, NULL, 0,
+ if (Lex->main_select_push())
+ MYSQL_YYABORT;
+ }
+ table_ident
+ {
+ if (unlikely(!Select->add_table_to_list(thd, $3, NULL, 0,
TL_READ, MDL_SHARED_HIGH_PRIO)))
MYSQL_YYABORT;
Lex->sql_command= SQLCOM_BACKUP_LOCK;
+ Lex->pop_select(); //main select
}
| UNLOCK_SYM
{
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index aebbb145f96..a72b4a7594b 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -9097,9 +9097,13 @@ rename:
RENAME table_or_tables
{
Lex->sql_command= SQLCOM_RENAME_TABLE;
+ if (Lex->main_select_push())
+ MYSQL_YYABORT;
}
table_to_table_list
- {}
+ {
+ Lex->pop_select(); //main select
+ }
| RENAME USER_SYM clear_privileges rename_list
{
Lex->sql_command = SQLCOM_RENAME_USER;
@@ -9197,9 +9201,13 @@ preload:
LEX *lex=Lex;
lex->sql_command=SQLCOM_PRELOAD_KEYS;
lex->alter_info.reset();
+ if (lex->main_select_push())
+ MYSQL_YYABORT;
}
preload_list_or_parts
- {}
+ {
+ Lex->pop_select(); //main select
+ }
;
preload_list_or_parts:
@@ -13363,11 +13371,14 @@ do:
{
LEX *lex=Lex;
lex->sql_command = SQLCOM_DO;
+ if (lex->main_select_push())
+ MYSQL_YYABORT;
mysql_init_select(lex);
}
expr_list
{
Lex->insert_list= $3;
+ Lex->pop_select(); //main select
}
;
@@ -13385,11 +13396,16 @@ drop:
}
table_list opt_lock_wait_timeout opt_restrict
{}
- | DROP INDEX_SYM opt_if_exists_table_element ident ON table_ident opt_lock_wait_timeout
+ | DROP INDEX_SYM
+ {
+ if (Lex->main_select_push())
+ MYSQL_YYABORT;
+ }
+ opt_if_exists_table_element ident ON table_ident opt_lock_wait_timeout
{
LEX *lex=Lex;
Alter_drop *ad= (new (thd->mem_root)
- Alter_drop(Alter_drop::KEY, $4.str, $3));
+ Alter_drop(Alter_drop::KEY, $5.str, $4));
if (unlikely(ad == NULL))
MYSQL_YYABORT;
lex->sql_command= SQLCOM_DROP_INDEX;
@@ -13397,10 +13413,11 @@ drop:
lex->alter_info.flags= ALTER_DROP_INDEX;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
if (unlikely(!lex->current_select->
- add_table_to_list(thd, $6, NULL, TL_OPTION_UPDATING,
+ add_table_to_list(thd, $7, NULL, TL_OPTION_UPDATING,
TL_READ_NO_INSERT,
MDL_SHARED_UPGRADABLE)))
MYSQL_YYABORT;
+ Lex->pop_select(); //main select
}
| DROP DATABASE opt_if_exists ident
{
@@ -14685,6 +14702,8 @@ describe:
describe_command table_ident
{
LEX *lex= Lex;
+ if (lex->main_select_push())
+ MYSQL_YYABORT;
mysql_init_select(lex);
lex->current_select->parsing_place= SELECT_LIST;
lex->sql_command= SQLCOM_SHOW_FIELDS;
@@ -14696,6 +14715,7 @@ describe:
opt_describe_column
{
Select->parsing_place= NO_MATTER;
+ Lex->pop_select(); //main select
}
| describe_command opt_extended_describe
{ Lex->describe|= DESCRIBE_NORMAL; }
@@ -14916,12 +14936,18 @@ backup_statements:
Lex->backup_stage= (backup_stages) (type-1);
break;
}
- | LOCK_SYM table_ident
+ | LOCK_SYM
{
- if (unlikely(!Select->add_table_to_list(thd, $2, NULL, 0,
+ if (Lex->main_select_push())
+ MYSQL_YYABORT;
+ }
+ table_ident
+ {
+ if (unlikely(!Select->add_table_to_list(thd, $3, NULL, 0,
TL_READ, MDL_SHARED_HIGH_PRIO)))
MYSQL_YYABORT;
Lex->sql_command= SQLCOM_BACKUP_LOCK;
+ Lex->pop_select(); //main select
}
| UNLOCK_SYM
{