From 541c94fcf1f95e22aef9cff615ebe3c2594f0a0a Mon Sep 17 00:00:00 2001 From: "pem@mysql.com" <> Date: Thu, 12 Jun 2003 15:31:20 +0200 Subject: [PATCH] Fixed bug #643, which caused intermittent crashes in net_printf() with repeated syntax errors in stored procedures. --- mysql-test/r/sp-error.result | 6 ++++++ mysql-test/t/sp-error.test | 10 ++++++++++ sql/sp_head.cc | 1 + 3 files changed, 17 insertions(+) diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 99bdfc25ba8..0c1db1703ac 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -1,4 +1,10 @@ delete from mysql.proc; +create procedure syntaxerror(t int); +You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +create procedure syntaxerror(t int); +You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +create procedure syntaxerror(t int); +You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 create procedure proc1() set @x = 42; create function func1() returns int diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 93852b2219d..8fa0b3c55cf 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -7,6 +7,16 @@ delete from mysql.proc; delimiter |; +# This should give three syntax errors (sometimes crashed; bug #643) +# (Unfortunately, this is not a 100% test, on some platforms this +# passed despite the bug.) +--error 1064 +create procedure syntaxerror(t int)| +--error 1064 +create procedure syntaxerror(t int)| +--error 1064 +create procedure syntaxerror(t int)| + # Check that we get the right error, i.e. UDF declaration parses correctly, # but foo.so doesn't exist. # QQ This generates an error message containing a misleading errno which diff --git a/sql/sp_head.cc b/sql/sp_head.cc index f4bfb74dd3c..04a7ef8aa09 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -376,6 +376,7 @@ sp_head::reset_lex(THD *thd) /* We must reset ptr and end_of_query again */ sublex->ptr= m_lex->ptr; sublex->end_of_query= m_lex->end_of_query; + sublex->tok_start= m_lex->tok_start; /* And keep the SP stuff too */ sublex->sphead= m_lex->sphead; sublex->spcont= m_lex->spcont;