From 7e6bade23bf5fbaf6cdb76e2fce2f76cfc533a7a Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Thu, 29 Jul 2004 17:33:45 +0200 Subject: [PATCH] Fixed BUG#434: Stored procedure which drops itself causes crash. Simply disallow it, just as we disallow creation of routines from within other SPs. --- include/mysqld_error.h | 3 ++- mysql-test/r/sp-error.result | 4 ++++ mysql-test/t/sp-error.test | 9 +++++++++ sql/share/czech/errmsg.txt | 1 + sql/share/danish/errmsg.txt | 1 + sql/share/dutch/errmsg.txt | 1 + sql/share/english/errmsg.txt | 1 + sql/share/estonian/errmsg.txt | 1 + sql/share/french/errmsg.txt | 1 + sql/share/german/errmsg.txt | 1 + sql/share/greek/errmsg.txt | 1 + sql/share/hungarian/errmsg.txt | 1 + sql/share/italian/errmsg.txt | 1 + sql/share/japanese/errmsg.txt | 1 + sql/share/korean/errmsg.txt | 1 + sql/share/norwegian-ny/errmsg.txt | 1 + sql/share/norwegian/errmsg.txt | 1 + sql/share/polish/errmsg.txt | 1 + sql/share/portuguese/errmsg.txt | 1 + sql/share/romanian/errmsg.txt | 1 + sql/share/russian/errmsg.txt | 1 + sql/share/serbian/errmsg.txt | 1 + sql/share/slovak/errmsg.txt | 1 + sql/share/spanish/errmsg.txt | 1 + sql/share/swedish/errmsg.txt | 1 + sql/share/ukrainian/errmsg.txt | 1 + sql/sql_yacc.yy | 10 ++++++++++ 27 files changed, 48 insertions(+), 1 deletion(-) diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 59146f63179..9798c13c075 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -372,4 +372,5 @@ #define ER_WARN_VIEW_MERGE 1353 #define ER_WARN_VIEW_WITHOUT_KEY 1354 #define ER_VIEW_INVALID 1355 -#define ER_ERROR_MESSAGES 356 +#define ER_SP_NO_DROP_SP 1356 +#define ER_ERROR_MESSAGES 357 diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index c34a27cc8f7..02aaa646646 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -413,4 +413,8 @@ call bug2653_2(2, @b)| ERROR 42S22: Unknown column 'aa' in 'order clause' drop procedure bug2653_1| drop procedure bug2653_2| +create procedure bug4344() drop procedure bug4344| +ERROR HY000: Can't drop a PROCEDURE from within another stored routine +create procedure bug4344() drop function bug4344| +ERROR HY000: Can't drop a FUNCTION from within another stored routine drop table t1| diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index e1a3a610c9c..ecba664dfca 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -576,6 +576,15 @@ call bug2653_2(2, @b)| drop procedure bug2653_1| drop procedure bug2653_2| +# +# BUG#4344 +# +--error 1356 +create procedure bug4344() drop procedure bug4344| +--error 1356 +create procedure bug4344() drop function bug4344| + + drop table t1| delimiter ;| diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 9eedbbd9990..b093a3a9091 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -368,3 +368,4 @@ character-set=latin2 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index e9dd993922b..eb7af69f061 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -362,3 +362,4 @@ character-set=latin1 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index d8dde6cba35..0d287daf11e 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -370,3 +370,4 @@ character-set=latin1 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index d6f941d21f7..2e4c5bc0ac4 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -359,3 +359,4 @@ character-set=latin1 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index a23ae3c66fe..821852db13b 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -364,3 +364,4 @@ character-set=latin7 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 3064d2f36a9..f9629485136 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -359,3 +359,4 @@ character-set=latin1 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index 30916e682fa..b3e0b2fae05 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -371,3 +371,4 @@ character-set=latin1 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index d87b98cf39b..9a470b81d9e 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -359,3 +359,4 @@ character-set=greek "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 37fa6a86b49..9e7ea311c2a 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -361,3 +361,4 @@ character-set=latin2 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index c103537d7e2..fc56b72b79f 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -359,3 +359,4 @@ character-set=latin1 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 6783aee5a30..d148fd3f897 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -361,3 +361,4 @@ character-set=ujis "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index 472f0d6771d..1e3103c03dd 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -359,3 +359,4 @@ character-set=euckr "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index 369b8329397..83ec486f25d 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -361,3 +361,4 @@ character-set=latin1 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 5114b224c0b..8fb651dd2f2 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -361,3 +361,4 @@ character-set=latin1 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 3a45d8fe461..76006c97c5e 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -363,3 +363,4 @@ character-set=latin2 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index 58ec02d4bf2..56a95008a2b 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -360,3 +360,4 @@ character-set=latin1 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index c2d67e97e50..f25b81b6577 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -363,3 +363,4 @@ character-set=latin2 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index cf5c9d08582..907cece485f 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -361,3 +361,4 @@ character-set=koi8r "Алгоритм слияния view не может быть использован сейчас (алгоритм будет неопеределенным)" "Обновляемый view не содержит ключа использованной в нем таблиц(ы)" "View '%-.64s.%-.64s' ссылается на несуществующие таблицы или слолбцы" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index eca688cd2ac..cef6fcc1533 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -365,3 +365,4 @@ character-set=cp1250 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 89ea0d687cc..4fc4c8808fc 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -367,3 +367,4 @@ character-set=latin2 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 0e2e9180c62..117295b9083 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -361,3 +361,4 @@ character-set=latin1 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index e0ff1f9a52d..bafba304e3a 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -359,3 +359,4 @@ character-set=latin1 "View merge algorithm can't be used here for now (assumed undefined algorithm)" "View being update does not have complete key of underlying table in it" "View '%-.64s.%-.64s' references invalid table(s) or column(s)" +"Can't drop a %s from within another stored routine" diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index a050f8e11d0..a043b6eb651 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -364,3 +364,4 @@ character-set=koi8u "Алгоритм зливання view не може бути використаний зараз (алгоритм буде невизначений)" "View, що оновлюеться, не м╕стить повного ключа таблиц╕(ь), що викор╕стана в ньюому" "View '%-.64s.%-.64s' посила╓тся на не╕снуюч╕ таблиц╕ або стовбц╕" +"Can't drop a %s from within another stored routine" diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 2939090e948..e93f2ac089b 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -5187,6 +5187,11 @@ drop: | DROP FUNCTION_SYM if_exists sp_name opt_restrict { LEX *lex=Lex; + if (lex->sphead) + { + net_printf(YYTHD, ER_SP_NO_DROP_SP, "FUNCTION"); + YYABORT; + } lex->sql_command = SQLCOM_DROP_FUNCTION; lex->drop_if_exists= $3; lex->spname= $4; @@ -5194,6 +5199,11 @@ drop: | DROP PROCEDURE if_exists sp_name opt_restrict { LEX *lex=Lex; + if (lex->sphead) + { + net_printf(YYTHD, ER_SP_NO_DROP_SP, "PROCEDURE"); + YYABORT; + } lex->sql_command = SQLCOM_DROP_PROCEDURE; lex->drop_if_exists= $3; lex->spname= $4;