summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2020-07-27 13:00:53 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2020-07-27 14:28:23 +0200
commit2eac8a12a6f49f3b79fa23a5cd8c139d5a48779f (patch)
tree579dcfac9a37159d59b3952f74a1b0858df1beda
parent6b78dc22569f5015afad2a84b8b8d42810992ac1 (diff)
downloadmariadb-git-bb-10.4-MDEV-21998-2.tar.gz
fix obvious bugs hidden by current_select assigned to builtin selectbb-10.4-MDEV-21998-2
-rw-r--r--sql/sql_lex.cc9
-rw-r--r--sql/sql_lex.h2
-rw-r--r--sql/sql_yacc.yy23
-rw-r--r--sql/sql_yacc_ora.yy30
4 files changed, 38 insertions, 26 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 53e4b020ff6..f8b93abd4ae 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -6182,6 +6182,7 @@ bool LEX::sp_for_loop_cursor_declarations(THD *thd,
LEX_CSTRING name;
uint coffs, param_count= 0;
const sp_pcursor *pcursor;
+ DBUG_ENTER("LEX::sp_for_loop_cursor_declarations");
if ((item_splocal= item->get_item_splocal()))
name= item_splocal->m_name;
@@ -6213,23 +6214,23 @@ bool LEX::sp_for_loop_cursor_declarations(THD *thd,
else
{
thd->parse_error();
- return true;
+ DBUG_RETURN(true);
}
if (unlikely(!(pcursor= spcont->find_cursor_with_error(&name, &coffs,
false)) ||
pcursor->check_param_count_with_error(param_count)))
- return true;
+ DBUG_RETURN(true);
if (!(loop->m_index= sp_add_for_loop_cursor_variable(thd, index,
pcursor, coffs,
bounds.m_index,
item_func_sp)))
- return true;
+ DBUG_RETURN(true);
loop->m_target_bound= NULL;
loop->m_direction= bounds.m_direction;
loop->m_cursor_offset= coffs;
loop->m_implicit_cursor= bounds.m_implicit_cursor;
- return false;
+ DBUG_RETURN(false);
}
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index d0a18d4c578..8e8a62e7a4f 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -4812,7 +4812,7 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr);
Item* handle_sql2003_note184_exception(THD *thd, Item* left, bool equal,
Item *expr);
-void sp_create_assignment_lex(THD *thd, bool no_lookahead);
+bool sp_create_assignment_lex(THD *thd, bool no_lookahead);
bool sp_create_assignment_instr(THD *thd, bool no_lookahead);
void mark_or_conds_to_avoid_pushdown(Item *cond);
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 6ae6c22559a..88d3669e008 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -509,7 +509,7 @@ Item* handle_sql2003_note184_exception(THD *thd, Item* left, bool equal,
@param no_lookahead True if the parser has no lookahead
*/
-void sp_create_assignment_lex(THD *thd, bool no_lookahead)
+bool sp_create_assignment_lex(THD *thd, bool no_lookahead)
{
LEX *lex= thd->lex;
@@ -522,6 +522,8 @@ void sp_create_assignment_lex(THD *thd, bool no_lookahead)
/* Set new LEX as if we at start of set rule. */
lex->sql_command= SQLCOM_SET_OPTION;
+ if (lex->main_select_push())
+ return true;
mysql_init_select(lex);
lex->var_list.empty();
lex->autocommit= 0;
@@ -532,8 +534,8 @@ void sp_create_assignment_lex(THD *thd, bool no_lookahead)
lex->sphead->m_tmp_query= lip->get_tok_end();
/* Inherit from outer lex. */
lex->option_type= old_lex->option_type;
- lex->main_select_push();
}
+ return false;
}
@@ -16453,7 +16455,8 @@ set:
MYSQL_YYABORT;
lex->set_stmt_init();
lex->var_list.empty();
- sp_create_assignment_lex(thd, yychar == YYEMPTY);
+ if (sp_create_assignment_lex(thd, yychar == YYEMPTY))
+ MYSQL_YYABORT;
}
start_option_value_list
{
@@ -16541,7 +16544,8 @@ option_value_list_continued:
/* Repeating list of option values after first option value. */
option_value_list:
{
- sp_create_assignment_lex(thd, yychar == YYEMPTY);
+ if (sp_create_assignment_lex(thd, yychar == YYEMPTY))
+ MYSQL_YYABORT;
}
option_value
{
@@ -16550,7 +16554,8 @@ option_value_list:
}
| option_value_list ','
{
- sp_create_assignment_lex(thd, yychar == YYEMPTY);
+ if (sp_create_assignment_lex(thd, yychar == YYEMPTY))
+ MYSQL_YYABORT;
}
option_value
{
@@ -17346,7 +17351,7 @@ grant_ident:
'*'
{
LEX *lex= Lex;
- if (unlikely(lex->copy_db_to(&lex->current_select->db)))
+ if (unlikely(lex->copy_db_to(&lex->first_select_lex()->db)))
MYSQL_YYABORT;
if (lex->grant == GLOBAL_ACLS)
lex->grant = DB_ACLS & ~GRANT_ACL;
@@ -17356,7 +17361,7 @@ grant_ident:
| ident '.' '*'
{
LEX *lex= Lex;
- lex->current_select->db= $1;
+ lex->first_select_lex()->db= $1;
if (lex->grant == GLOBAL_ACLS)
lex->grant = DB_ACLS & ~GRANT_ACL;
else if (unlikely(lex->columns.elements))
@@ -17365,7 +17370,7 @@ grant_ident:
| '*' '.' '*'
{
LEX *lex= Lex;
- lex->current_select->db= null_clex_str;
+ lex->first_select_lex()->db= null_clex_str;
if (lex->grant == GLOBAL_ACLS)
lex->grant= GLOBAL_ACLS & ~GRANT_ACL;
else if (unlikely(lex->columns.elements))
@@ -17374,7 +17379,7 @@ grant_ident:
| table_ident
{
LEX *lex=Lex;
- if (unlikely(!lex->current_select->
+ if (unlikely(!lex->first_select_lex()->
add_table_to_list(thd, $1,NULL,
TL_OPTION_UPDATING)))
MYSQL_YYABORT;
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index c42c8e68e96..9d5e42355b9 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -9253,8 +9253,8 @@ adm_partition:
cache_keys_spec:
{
Lex->first_select_lex()->alloc_index_hints(thd);
- Select->set_index_hint_type(INDEX_HINT_USE,
- INDEX_HINT_MASK_ALL);
+ Lex->first_select_lex()->set_index_hint_type(INDEX_HINT_USE,
+ INDEX_HINT_MASK_ALL);
}
cache_key_list_or_empty
;
@@ -16622,7 +16622,8 @@ set:
MYSQL_YYABORT;
lex->set_stmt_init();
lex->var_list.empty();
- sp_create_assignment_lex(thd, yychar == YYEMPTY);
+ if (sp_create_assignment_lex(thd, yychar == YYEMPTY))
+ MYSQL_YYABORT;
}
start_option_value_list
{
@@ -16657,7 +16658,8 @@ set_assign:
LEX *lex=Lex;
lex->set_stmt_init();
lex->var_list.empty();
- sp_create_assignment_lex(thd, yychar == YYEMPTY);
+ if(sp_create_assignment_lex(thd, yychar == YYEMPTY))
+ MYSQL_YYABORT;
}
set_expr_or_default
{
@@ -16670,7 +16672,8 @@ set_assign:
LEX *lex=Lex;
lex->set_stmt_init();
lex->var_list.empty();
- sp_create_assignment_lex(thd, yychar == YYEMPTY);
+ if (sp_create_assignment_lex(thd, yychar == YYEMPTY))
+ MYSQL_YYABORT;
}
set_expr_or_default
{
@@ -16690,7 +16693,8 @@ set_assign:
}
lex->set_stmt_init();
lex->var_list.empty();
- sp_create_assignment_lex(thd, yychar == YYEMPTY);
+ if (sp_create_assignment_lex(thd, yychar == YYEMPTY))
+ MYSQL_YYABORT;
}
set_expr_or_default
{
@@ -16760,7 +16764,8 @@ option_value_list_continued:
/* Repeating list of option values after first option value. */
option_value_list:
{
- sp_create_assignment_lex(thd, yychar == YYEMPTY);
+ if (sp_create_assignment_lex(thd, yychar == YYEMPTY))
+ MYSQL_YYABORT;
}
option_value
{
@@ -16769,7 +16774,8 @@ option_value_list:
}
| option_value_list ','
{
- sp_create_assignment_lex(thd, yychar == YYEMPTY);
+ if (sp_create_assignment_lex(thd, yychar == YYEMPTY))
+ MYSQL_YYABORT;
}
option_value
{
@@ -17565,7 +17571,7 @@ grant_ident:
'*'
{
LEX *lex= Lex;
- if (unlikely(lex->copy_db_to(&lex->current_select->db)))
+ if (unlikely(lex->copy_db_to(&lex->first_select_lex()->db)))
MYSQL_YYABORT;
if (lex->grant == GLOBAL_ACLS)
lex->grant = DB_ACLS & ~GRANT_ACL;
@@ -17575,7 +17581,7 @@ grant_ident:
| ident '.' '*'
{
LEX *lex= Lex;
- lex->current_select->db= $1;
+ lex->first_select_lex()->db= $1;
if (lex->grant == GLOBAL_ACLS)
lex->grant = DB_ACLS & ~GRANT_ACL;
else if (unlikely(lex->columns.elements))
@@ -17584,7 +17590,7 @@ grant_ident:
| '*' '.' '*'
{
LEX *lex= Lex;
- lex->current_select->db= null_clex_str;
+ lex->first_select_lex()->db= null_clex_str;
if (lex->grant == GLOBAL_ACLS)
lex->grant= GLOBAL_ACLS & ~GRANT_ACL;
else if (unlikely(lex->columns.elements))
@@ -17593,7 +17599,7 @@ grant_ident:
| table_ident
{
LEX *lex=Lex;
- if (unlikely(!lex->current_select->
+ if (unlikely(!lex->first_select_lex()->
add_table_to_list(thd, $1,NULL,
TL_OPTION_UPDATING)))
MYSQL_YYABORT;