From 027c5a6dac461d62c2d51567bf8997afe415c5a2 Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Wed, 2 Mar 2005 17:25:58 +0100 Subject: [PATCH] Fixed BUG#8762: Stored Procedures: Inconsistent behavior of DROP PROCEDURE IF EXISTS statement. --- mysql-test/r/sp.result | 4 ++++ mysql-test/t/sp.test | 13 +++++++++++++ sql/sp.cc | 8 +++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index b4198a5f467..24045bae430 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -2204,6 +2204,10 @@ call bug8757()| delete from t1| delete from t2| drop procedure bug8757| +drop procedure if exists bug8762| +drop procedure if exists bug8762; create procedure bug8762() begin end| +drop procedure if exists bug8762; create procedure bug8762() begin end| +drop procedure bug8762| drop table if exists fac| create table fac (n int unsigned not null primary key, f bigint unsigned)| drop procedure if exists ifac| diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index cfb5de7ddd0..439ace881d1 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -2714,6 +2714,19 @@ delete from t2| drop procedure bug8757| +# +# BUG#8762: Stored Procedures: Inconsistent behavior +# of DROP PROCEDURE IF EXISTS statement. +--disable_warnings +drop procedure if exists bug8762| +--enable_warnings +# Doesn't exist +drop procedure if exists bug8762; create procedure bug8762() begin end| +# Does exist +drop procedure if exists bug8762; create procedure bug8762() begin end| +drop procedure bug8762| + + # # Some "real" examples # diff --git a/sql/sp.cc b/sql/sp.cc index 46b08c3e847..a57d90dbf7a 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -288,12 +288,14 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp) * in thd->lex (the unit and master stuff), and the easiest way to * do it is, is to call mysql_init_query(), but this unfortunately * resets teh value_list where we keep the CALL parameters. So we - * copy the list and then restore it. + * copy the list and then restore it. (... and found_semicolon too). */ - List vals= thd->lex->value_list; + List tmpvals= thd->lex->value_list; + char *tmpfsc= thd->lex->found_semicolon; lex_start(thd, (uchar*)defstr.c_ptr(), defstr.length()); - thd->lex->value_list= vals; + thd->lex->value_list= tmpvals; + thd->lex->found_semicolon= tmpfsc; } if (yyparse(thd) || thd->is_fatal_error || thd->lex->sphead == NULL)