diff options
author | unknown <pem@mysql.com> | 2003-03-26 12:29:58 +0100 |
---|---|---|
committer | unknown <pem@mysql.com> | 2003-03-26 12:29:58 +0100 |
commit | 3946b8235c6f4dfbb5a1aeefed5b620bf89df34e (patch) | |
tree | 457c34fe3030c8bbfb9f64357cd27f37a4ab6bd8 | |
parent | fa870804d37c27a69551c9767b9a17224fe495b9 (diff) | |
download | mariadb-git-3946b8235c6f4dfbb5a1aeefed5b620bf89df34e.tar.gz |
Added IF EXISTS to DROP PROCEDURE|FUNCTION.
Changed another unecessary use of Item_string into LEX_STRING (in sp_pcontext).
Docs/sp-implemented.txt:
Added IF EXISTS to DROP PROCEDURE|FUNCTION
mysql-test/r/sp-error.result:
Added IF EXISTS to DROP PROCEDURE|FUNCTION
mysql-test/t/sp-error.test:
Added IF EXISTS to DROP PROCEDURE|FUNCTION
sql/sp_pcontext.cc:
Changed another unecessary use of Item_string into LEX_STRING.
sql/sp_pcontext.h:
Changed another unecessary use of Item_string into LEX_STRING.
sql/sql_parse.cc:
Added IF EXISTS to DROP PROCEDURE|FUNCTION
sql/sql_yacc.yy:
Added IF EXISTS to DROP PROCEDURE|FUNCTION
-rw-r--r-- | Docs/sp-implemented.txt | 2 | ||||
-rw-r--r-- | mysql-test/r/sp-error.result | 3 | ||||
-rw-r--r-- | mysql-test/t/sp-error.test | 1 | ||||
-rw-r--r-- | sql/sp_pcontext.cc | 11 | ||||
-rw-r--r-- | sql/sp_pcontext.h | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 9 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 10 |
7 files changed, 26 insertions, 12 deletions
diff --git a/Docs/sp-implemented.txt b/Docs/sp-implemented.txt index 1878c99b7ed..41e7c4b2923 100644 --- a/Docs/sp-implemented.txt +++ b/Docs/sp-implemented.txt @@ -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) diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index ee99e871c3e..ad1510c27f6 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -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; diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 343b30ea8da..dd9becc631d 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -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 diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc index 9d22c6be62b..94eb8df4b95 100644 --- a/sql/sp_pcontext.cc +++ b/sql/sp_pcontext.cc @@ -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; diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h index 6ab38e77017..c5b0f1d410b 100644 --- a/sql/sp_pcontext.h +++ b/sql/sp_pcontext.h @@ -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 diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0fa05e13f9c..dbd8dc5ce8d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -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; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 43cfe94bdea..133f2e18ac6 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -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; } ; |