Commit e08f87d5 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

fix obvious bugs hidden by current_select assigned to builtin select

parent c6eb21cd
......@@ -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);
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment