Commit 6f619804 authored by unknown's avatar unknown

Fixed BUG#9538: SProc: Creation fails if we try to SET system variable

                  using @@var_name in proc
  Made sure we don't lose the tokenizer state when swapping lex in during SET
  parsing.


mysql-test/r/sp.result:
  New test case for BUG#9538.
mysql-test/t/sp.test:
  New test case for BUG#9538.
sql/sp_head.cc:
  Keep lex->next_state when swapping lex during SP parsing (for SET mainly),
  otherwise the tokenizer gets confused.
parent c5d4befb
...@@ -3079,4 +3079,17 @@ one 1 ...@@ -3079,4 +3079,17 @@ one 1
delete from t1| delete from t1|
drop procedure bug9565_sub| drop procedure bug9565_sub|
drop procedure bug9565| drop procedure bug9565|
drop procedure if exists bug9538|
create procedure bug9538()
set @@sort_buffer_size = 1000000|
set @x = @@sort_buffer_size|
select @@sort_buffer_size|
@@sort_buffer_size
262136
call bug9538()|
select @@sort_buffer_size|
@@sort_buffer_size
1000000
set @@sort_buffer_size = @x|
drop procedure bug9538|
drop table t1,t2; drop table t1,t2;
...@@ -3855,6 +3855,25 @@ drop procedure bug9565_sub| ...@@ -3855,6 +3855,25 @@ drop procedure bug9565_sub|
drop procedure bug9565| drop procedure bug9565|
#
# BUG#9538: SProc: Creation fails if we try to SET system variable
# using @@var_name in proc
#
--disable_warnings
drop procedure if exists bug9538|
--enable_warnings
create procedure bug9538()
set @@sort_buffer_size = 1000000|
set @x = @@sort_buffer_size|
select @@sort_buffer_size|
call bug9538()|
select @@sort_buffer_size|
set @@sort_buffer_size = @x|
drop procedure bug9538|
# #
# BUG#NNNN: New bug synopsis # BUG#NNNN: New bug synopsis
# #
......
...@@ -1023,6 +1023,7 @@ sp_head::reset_lex(THD *thd) ...@@ -1023,6 +1023,7 @@ sp_head::reset_lex(THD *thd)
DBUG_ENTER("sp_head::reset_lex"); DBUG_ENTER("sp_head::reset_lex");
LEX *sublex; LEX *sublex;
LEX *oldlex= thd->lex; LEX *oldlex= thd->lex;
my_lex_states state= oldlex->next_state; // Keep original next_state
(void)m_lex.push_front(oldlex); (void)m_lex.push_front(oldlex);
thd->lex= sublex= new st_lex; thd->lex= sublex= new st_lex;
...@@ -1030,6 +1031,11 @@ sp_head::reset_lex(THD *thd) ...@@ -1030,6 +1031,11 @@ sp_head::reset_lex(THD *thd)
/* Reset most stuff. The length arguments doesn't matter here. */ /* Reset most stuff. The length arguments doesn't matter here. */
lex_start(thd, oldlex->buf, (ulong) (oldlex->end_of_query - oldlex->ptr)); lex_start(thd, oldlex->buf, (ulong) (oldlex->end_of_query - oldlex->ptr));
/*
* next_state is normally the same (0), but it happens that we swap lex in
* "mid-sentence", so we must restore it.
*/
sublex->next_state= state;
/* We must reset ptr and end_of_query again */ /* We must reset ptr and end_of_query again */
sublex->ptr= oldlex->ptr; sublex->ptr= oldlex->ptr;
sublex->end_of_query= oldlex->end_of_query; sublex->end_of_query= oldlex->end_of_query;
......
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