Commit 25785647 authored by pem@mysql.com's avatar pem@mysql.com

Added IF EXISTS to DROP PROCEDURE|FUNCTION.

Changed another unecessary use of Item_string into LEX_STRING (in sp_pcontext).
parent 0d95f36a
......@@ -35,7 +35,7 @@ List of what's implemented:
Is parsed, but a no-op (as there are no characteristics implemented yet).
CASCADE/RESTRICT is not implemented (and CASCADE probably will not be).
- DROP PROCEDURE|FUNCTION name
- DROP PROCEDURE|FUNCTION [IF EXISTS] name
CASCADE/RESTRICT is not implemented (and CASCADE probably will not be).
- CALL name (args)
......
......@@ -25,6 +25,9 @@ drop function foo;
FUNCTION foo does not exist
call foo();
PROCEDURE foo does not exist
drop procedure if exists foo;
Warnings:
Warning 1256 PROCEDURE foo does not exist
create procedure foo()
foo: loop
leave bar;
......
......@@ -48,6 +48,7 @@ drop procedure foo|
drop function foo|
--error 1256
call foo()|
drop procedure if exists foo|
# LEAVE/ITERATE with no match
--error 1259
......
......@@ -65,13 +65,12 @@ sp_pcontext::find_pvar(LEX_STRING *name)
while (i-- > 0)
{
uint len= m_pvar[i].name->const_string()->length();
uint len= (m_pvar[i].name.length > name->length ?
m_pvar[i].name.length : name->length);
if (name->length > len)
len= name->length;
if (my_strncasecmp(system_charset_info,
name->str,
m_pvar[i].name->const_string()->ptr(),
m_pvar[i].name.str,
len) == 0)
{
return m_pvar + i;
......@@ -90,8 +89,8 @@ sp_pcontext::push(LEX_STRING *name, enum enum_field_types type,
{
if (m_i == m_framesize)
m_framesize += 1;
m_pvar[m_i].name= new Item_string(name->str, name->length,
default_charset_info);
m_pvar[m_i].name.str= name->str;
m_pvar[m_i].name.length= name->length,
m_pvar[m_i].type= type;
m_pvar[m_i].mode= mode;
m_pvar[m_i].offset= m_i;
......
......@@ -31,7 +31,7 @@ typedef enum
typedef struct
{
Item_string *name;
LEX_STRING name;
enum enum_field_types type;
sp_param_mode_t mode;
uint offset; // Offset in current frame
......
......@@ -3101,6 +3101,15 @@ mysql_execute_command(THD *thd)
send_ok(thd);
break;
case SP_KEY_NOT_FOUND:
if (lex->drop_if_exists)
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST),
SP_COM_STRING(lex), lex->udf.name.str);
res= 0;
send_ok(thd);
break;
}
net_printf(thd, ER_SP_DOES_NOT_EXIST, SP_COM_STRING(lex),
lex->udf.name.str);
goto error;
......
......@@ -3699,17 +3699,19 @@ drop:
lex->drop_if_exists=$3;
lex->name=$4.str;
}
| DROP FUNCTION_SYM IDENT_sys opt_restrict
| DROP FUNCTION_SYM if_exists IDENT_sys opt_restrict
{
LEX *lex=Lex;
lex->sql_command = SQLCOM_DROP_FUNCTION;
lex->udf.name= $3;
lex->drop_if_exists= $3;
lex->udf.name= $4;
}
| DROP PROCEDURE ident opt_restrict
| DROP PROCEDURE if_exists IDENT_sys opt_restrict
{
LEX *lex=Lex;
lex->sql_command = SQLCOM_DROP_PROCEDURE;
lex->udf.name= $3;
lex->drop_if_exists= $3;
lex->udf.name= $4;
}
;
......
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