summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <pem@mysql.com>2005-07-15 17:24:19 +0200
committerunknown <pem@mysql.com>2005-07-15 17:24:19 +0200
commit6f619804fc60ef15a19caf8a5da98a5fc9bec44e (patch)
tree43e64a64bd24fe23cfa5b17f4936a549674373b1
parentc5d4befbde15699e02231ea012ef462cc81e7c38 (diff)
downloadmariadb-git-6f619804fc60ef15a19caf8a5da98a5fc9bec44e.tar.gz
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.
-rw-r--r--mysql-test/r/sp.result13
-rw-r--r--mysql-test/t/sp.test19
-rw-r--r--sql/sp_head.cc6
3 files changed, 38 insertions, 0 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 345de49c21d..2bfe975f656 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -3079,4 +3079,17 @@ one 1
delete from t1|
drop procedure bug9565_sub|
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;
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 13de2090a84..342fd0d9538 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -3856,6 +3856,25 @@ 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
#
#--disable_warnings
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 272456d8c8e..02c006d01ee 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -1023,6 +1023,7 @@ sp_head::reset_lex(THD *thd)
DBUG_ENTER("sp_head::reset_lex");
LEX *sublex;
LEX *oldlex= thd->lex;
+ my_lex_states state= oldlex->next_state; // Keep original next_state
(void)m_lex.push_front(oldlex);
thd->lex= sublex= new st_lex;
@@ -1030,6 +1031,11 @@ sp_head::reset_lex(THD *thd)
/* Reset most stuff. The length arguments doesn't matter here. */
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 */
sublex->ptr= oldlex->ptr;
sublex->end_of_query= oldlex->end_of_query;