diff --git a/sql/sql_lex.h b/sql/sql_lex.h index f3ec34b6d4c..0918c223d3c 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -3386,5 +3386,9 @@ bool is_keyword(const char *name, uint len); 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_instr(THD *thd, bool no_lookahead); + #endif /* MYSQL_SERVER */ #endif /* SQL_LEX_INCLUDED */ diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index b7d382f1fc1..de5b6b36d8e 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -700,7 +700,7 @@ bool LEX::add_select_to_union_list(bool is_union_distinct, @param no_lookahead True if the parser has no lookahead */ -static void sp_create_assignment_lex(THD *thd, bool no_lookahead) +void sp_create_assignment_lex(THD *thd, bool no_lookahead) { LEX *lex= thd->lex; @@ -738,7 +738,7 @@ static void sp_create_assignment_lex(THD *thd, bool no_lookahead) @return false if success, true otherwise. */ -static bool sp_create_assignment_instr(THD *thd, bool no_lookahead) +bool sp_create_assignment_instr(THD *thd, bool no_lookahead) { LEX *lex= thd->lex; diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index 07346530d0f..5a213c1817d 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -227,116 +227,6 @@ find_sys_var_null_base(THD *thd, struct sys_var_with_base *tmp) } -/** - Create a separate LEX for each assignment if in SP. - - If we are in SP we want have own LEX for each assignment. - This is mostly because it is hard for several sp_instr_set - and sp_instr_set_trigger instructions share one LEX. - (Well, it is theoretically possible but adds some extra - overhead on preparation for execution stage and IMO less - robust). - - QQ: May be we should simply prohibit group assignments in SP? - - @see sp_create_assignment_instr - - @param thd Thread context - @param no_lookahead True if the parser has no lookahead -*/ - -static void sp_create_assignment_lex(THD *thd, bool no_lookahead) -{ - LEX *lex= thd->lex; - - if (lex->sphead) - { - Lex_input_stream *lip= &thd->m_parser_state->m_lip; - LEX *old_lex= lex; - lex->sphead->reset_lex(thd); - lex= thd->lex; - - /* Set new LEX as if we at start of set rule. */ - lex->sql_command= SQLCOM_SET_OPTION; - mysql_init_select(lex); - lex->var_list.empty(); - lex->autocommit= 0; - /* get_ptr() is only correct with no lookahead. */ - if (no_lookahead) - lex->sphead->m_tmp_query= lip->get_ptr(); - else - lex->sphead->m_tmp_query= lip->get_tok_end(); - /* Inherit from outer lex. */ - lex->option_type= old_lex->option_type; - } -} - - -/** - Create a SP instruction for a SET assignment. - - @see sp_create_assignment_lex - - @param thd Thread context - @param no_lookahead True if the parser has no lookahead - - @return false if success, true otherwise. -*/ - -static bool sp_create_assignment_instr(THD *thd, bool no_lookahead) -{ - LEX *lex= thd->lex; - - if (lex->sphead) - { - sp_head *sp= lex->sphead; - - if (!lex->var_list.is_empty()) - { - /* - We have assignment to user or system variable or - option setting, so we should construct sp_instr_stmt - for it. - */ - LEX_STRING qbuff; - sp_instr_stmt *i; - Lex_input_stream *lip= &thd->m_parser_state->m_lip; - - if (!(i= new (thd->mem_root) - sp_instr_stmt(sp->instructions(), lex->spcont, lex))) - return true; - - /* - Extract the query statement from the tokenizer. The - end is either lip->ptr, if there was no lookahead, - lip->tok_end otherwise. - */ - if (no_lookahead) - qbuff.length= lip->get_ptr() - sp->m_tmp_query; - else - qbuff.length= lip->get_tok_end() - sp->m_tmp_query; - - if (!(qbuff.str= (char*) alloc_root(thd->mem_root, - qbuff.length + 5))) - return true; - - strmake(strmake(qbuff.str, "SET ", 4), sp->m_tmp_query, - qbuff.length); - qbuff.length+= 4; - i->m_query= qbuff; - if (sp->add_instr(i)) - return true; - } - enum_var_type inner_option_type= lex->option_type; - if (lex->sphead->restore_lex(thd)) - return true; - /* Copy option_type to outer lex in case it has changed. */ - thd->lex->option_type= inner_option_type; - } - return false; -} - - #define bincmp_collation(X,Y) \ do \ { \