From b863798a7ccd1829a88459748d153f547f0298b8 Mon Sep 17 00:00:00 2001 From: "pem@mysql.com" <> Date: Wed, 15 Jan 2003 15:39:36 +0100 Subject: [PATCH] Fixed some basic error handling for SP functions in mysql_execute_command(). --- include/mysqld_error.h | 6 ++- sql/mysql_priv.h | 2 +- sql/share/czech/errmsg.txt | 6 ++- sql/share/danish/errmsg.txt | 6 ++- sql/share/dutch/errmsg.txt | 6 ++- sql/share/english/errmsg.txt | 7 ++- sql/share/estonian/errmsg.txt | 6 ++- sql/share/french/errmsg.txt | 6 ++- sql/share/german/errmsg.txt | 6 ++- sql/share/greek/errmsg.txt | 6 ++- sql/share/hungarian/errmsg.txt | 6 ++- sql/share/italian/errmsg.txt | 6 ++- sql/share/japanese/errmsg.txt | 6 ++- sql/share/korean/errmsg.txt | 6 ++- sql/share/norwegian-ny/errmsg.txt | 6 ++- sql/share/norwegian/errmsg.txt | 6 ++- sql/share/polish/errmsg.txt | 6 ++- sql/share/portuguese/errmsg.txt | 6 ++- sql/share/romanian/errmsg.txt | 6 ++- sql/share/russian/errmsg.txt | 6 ++- sql/share/serbian/errmsg.txt | 6 ++- sql/share/slovak/errmsg.txt | 6 ++- sql/share/spanish/errmsg.txt | 6 ++- sql/share/swedish/errmsg.txt | 6 ++- sql/share/ukrainian/errmsg.txt | 6 ++- sql/sp_head.cc | 10 ++-- sql/sql_parse.cc | 81 +++++++++++++++++++------------ 27 files changed, 175 insertions(+), 63 deletions(-) diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 377f714bfff..a339f44b258 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -266,4 +266,8 @@ #define ER_SELECT_REDUCED 1247 #define ER_TABLENAME_NOT_ALLOWED_HERE 1248 #define ER_NOT_SUPPORTED_AUTH_MODE 1249 -#define ER_ERROR_MESSAGES 250 +#define ER_SP_NO_RECURSIVE_CREATE 1250 +#define ER_SP_ALREADY_EXISTS 1251 +#define ER_SP_DOES_NOT_EXIST 1252 +#define ER_SP_DROP_FAILED 1253 +#define ER_ERROR_MESSAGES 254 diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 655e4d7b972..27115a2c252 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -349,7 +349,7 @@ extern "C" pthread_handler_decl(handle_one_connection,arg); extern "C" pthread_handler_decl(handle_bootstrap,arg); void end_thread(THD *thd,bool put_in_cache); void flush_thread_cache(); -void mysql_execute_command(THD *thd); +int mysql_execute_command(THD *thd); bool do_command(THD *thd); bool dispatch_command(enum enum_server_command command, THD *thd, char* packet, uint packet_length); diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 6c3196bfeba..d56f043b78f 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -259,4 +259,8 @@ v/* "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index dcc016511dd..9eea7e96e90 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -253,4 +253,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index 6091616fc4a..8ae5806594a 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -261,4 +261,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index 465992e63b2..76acfc558ff 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -250,4 +250,9 @@ "Every derived table must have it's own alias", "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" +"Failed to store PROCEDURE" diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index 43eb5de89a5..5caa6e8206c 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -255,4 +255,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index d7bb19c2876..eb5c147b35a 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -250,4 +250,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index 765fbd875e2..a13e2988335 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -260,4 +260,8 @@ "FЭr jede abgeleitete Tabelle muss ein eigener Alias angegeben werden.", "Select %u wurde wДhrend der Optimierung reduziert.", "Tabelle '%-.64s', die in einem der SELECT-Befehle verwendet wurde kann nicht in %-.32s verwendet werden." -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index 8831d4e47b9..c71559ba363 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -250,4 +250,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 8d6c321d316..0a570ea4879 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -252,4 +252,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index 451ad3e058b..9a1f7bd5e7f 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -250,4 +250,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 70ab2d6d42d..d110d9a766a 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -252,4 +252,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index c18c3ed3873..896f359a30a 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -250,4 +250,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index 9cd99613f52..d2f6c4816c2 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -252,4 +252,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 32fe6c30b34..7132e49b00b 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -252,4 +252,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 4b59a62f991..f7657e67dfa 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -254,4 +254,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index 7236bd86652..8b7d9c76d14 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -250,4 +250,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 0b8bbe1c219..4bd79d1b905 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -254,4 +254,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 2f1eedd207c..dd941428dfc 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -253,4 +253,8 @@ "Every derived table must have it's own alias" "Select %u был упразднен в процессе оптимизации", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index 75cfd73f3f0..8739f7bfa34 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -246,4 +246,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index de354f234c7..212ea72c727 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -258,4 +258,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index a528c3e6b36..87934beb754 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -251,4 +251,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 5473f4e8e42..c4964688102 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -250,4 +250,8 @@ "Every derived table must have it's own alias" "Select %u was reduced during optimisation", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 0b91786d1f3..0d8f89ac431 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -255,4 +255,8 @@ "Every derived table must have it's own alias" "Select %u was скасовано при оптимiзацii", "Table '%-.64s' from one of SELECT's can not be used in %-.32s" -"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" \ No newline at end of file +"Client does not support authentication protocol requested by server. Consider upgrading MySQL client" +"Can't create a PROCEDURE from within a PROCEDURE" +"PROCEDURE already exists" +"PROCEDURE does not exist" +"Failed to DROP PROCEDURE" diff --git a/sql/sp_head.cc b/sql/sp_head.cc index fdccedc788f..621b31f5e11 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -157,9 +157,6 @@ sp_head::execute(THD *thd) { // Execute instructions... uint ip= 0; - my_bool nsok= thd->net.no_send_ok; - - thd->net.no_send_ok= TRUE; // Don't send_ok() during execution while (ret == 0) { @@ -170,8 +167,6 @@ sp_head::execute(THD *thd) break; ret= i->execute(thd, &ip); } - - thd->net.no_send_ok= nsok; } // Don't copy back OUT values if we got an error @@ -323,18 +318,19 @@ int sp_instr_stmt::execute(THD *thd, uint *nextp) { LEX olex; // The other lex + int res; memcpy(&olex, &thd->lex, sizeof(LEX)); // Save the other lex memcpy(&thd->lex, &m_lex, sizeof(LEX)); // Use my own lex thd->lex.thd = thd; - mysql_execute_command(thd); + res= mysql_execute_command(thd); memcpy(&thd->lex, &olex, sizeof(LEX)); // Restore the other lex *nextp = m_ip+1; - return 0; + return res; } // diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0c32aca4b37..b82846706a8 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1482,7 +1482,7 @@ bool alloc_query(THD *thd, char *packet, ulong packet_length) ** Execute command saved in thd and current_lex->sql_command ****************************************************************************/ -void +int mysql_execute_command(THD *thd) { int res= 0; @@ -1513,7 +1513,7 @@ mysql_execute_command(THD *thd) given and the table list says the query should not be replicated */ if (table_rules_on && tables && !tables_ok(thd,tables)) - DBUG_VOID_RETURN; + return 0; #ifndef TO_BE_DELETED /* This is a workaround to deal with the shortcoming in 3.23.44-3.23.46 @@ -1549,7 +1549,7 @@ mysql_execute_command(THD *thd) { if (res < 0 || thd->net.report_error) send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0); - DBUG_VOID_RETURN; + return res; } } } @@ -1558,7 +1558,7 @@ mysql_execute_command(THD *thd) lex->unit.create_total_list(thd, lex, &tables)) || (table_rules_on && tables && thd->slave_thread && !tables_ok(thd,tables))) - DBUG_VOID_RETURN; + return 0; statistic_increment(com_stat[lex->sql_command],&LOCK_status); switch (lex->sql_command) { @@ -1597,7 +1597,7 @@ mysql_execute_command(THD *thd) if (!(result= new select_send())) { send_error(thd, ER_OUT_OF_RESOURCES); - DBUG_VOID_RETURN; + goto error; } else thd->send_explain_fields(result); @@ -1838,7 +1838,7 @@ mysql_execute_command(THD *thd) find_real_table_in_list(tables->next, tables->db, tables->real_name)) { net_printf(thd,ER_UPDATE_TABLE_USED,tables->real_name); - DBUG_VOID_RETURN; + return -1; } if (tables->next) { @@ -1918,7 +1918,7 @@ mysql_execute_command(THD *thd) if (thd->locked_tables || thd->active_transaction()) { send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION); - break; + goto error; } { LOCK_ACTIVE_MI; @@ -1929,7 +1929,7 @@ mysql_execute_command(THD *thd) case SQLCOM_ALTER_TABLE: #if defined(DONT_ALLOW_SHOW_COMMANDS) send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ - break; + goto error; #else { ulong priv=0; @@ -2019,7 +2019,7 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_BINLOGS: #ifdef DONT_ALLOW_SHOW_COMMANDS send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ - DBUG_VOID_RETURN; + goto error; #else { if (check_global_access(thd, SUPER_ACL)) @@ -2031,7 +2031,7 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_CREATE: #ifdef DONT_ALLOW_SHOW_COMMANDS send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ - DBUG_VOID_RETURN; + goto error; #else { if (check_db_used(thd, tables) || @@ -2103,7 +2103,7 @@ mysql_execute_command(THD *thd) if (select_lex->item_list.elements != lex->value_list.elements) { send_error(thd,ER_WRONG_VALUE_COUNT); - DBUG_VOID_RETURN; + goto error; } res= mysql_update(thd,tables, select_lex->item_list, @@ -2123,7 +2123,7 @@ mysql_execute_command(THD *thd) if (select_lex->item_list.elements != lex->value_list.elements) { send_error(thd,ER_WRONG_VALUE_COUNT); - DBUG_VOID_RETURN; + goto error; } { const char *msg= 0; @@ -2159,7 +2159,7 @@ mysql_execute_command(THD *thd) if (select_lex->item_list.elements != lex->value_list.elements) { send_error(thd,ER_WRONG_VALUE_COUNT); - DBUG_VOID_RETURN; + goto error; } res = mysql_insert(thd,tables,lex->field_list,lex->many_values, select_lex->item_list, lex->value_list, @@ -2199,7 +2199,7 @@ mysql_execute_command(THD *thd) if (find_real_table_in_list(tables->next, tables->db, tables->real_name)) { net_printf(thd,ER_UPDATE_TABLE_USED,tables->real_name); - DBUG_VOID_RETURN; + return -1; } /* Skip first table, which is the table we are inserting in */ @@ -2357,7 +2357,7 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_DATABASES: #if defined(DONT_ALLOW_SHOW_COMMANDS) send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ - DBUG_VOID_RETURN; + goto error; #else if ((specialflag & SPECIAL_SKIP_SHOW_DB) && check_global_access(thd, SHOW_DB_ACL)) @@ -2391,7 +2391,7 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_LOGS: #ifdef DONT_ALLOW_SHOW_COMMANDS send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ - DBUG_VOID_RETURN; + goto error; #else { if (grant_option && check_access(thd, FILE_ACL, any_db)) @@ -2404,7 +2404,7 @@ mysql_execute_command(THD *thd) /* FALL THROUGH */ #ifdef DONT_ALLOW_SHOW_COMMANDS send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ - DBUG_VOID_RETURN; + goto error; #else { char *db=select_lex->db ? select_lex->db : thd->db; @@ -2440,7 +2440,7 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_FIELDS: #ifdef DONT_ALLOW_SHOW_COMMANDS send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ - DBUG_VOID_RETURN; + goto error; #else { char *db=tables->db; @@ -2465,7 +2465,7 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_KEYS: #ifdef DONT_ALLOW_SHOW_COMMANDS send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ - DBUG_VOID_RETURN; + goto error; #else { char *db=tables->db; @@ -2813,13 +2813,17 @@ mysql_execute_command(THD *thd) break; case SQLCOM_CREATE_PROCEDURE: if (!lex->sphead) - res= -1; + { + send_error(thd, ER_SP_NO_RECURSIVE_CREATE); + goto error; + } else { res= lex->sphead->create(thd); - if (res < 0) + if (res != 0) { - // QQ Error! + send_error(thd, ER_SP_ALREADY_EXISTS); + goto error; } send_ok(thd); } @@ -2833,14 +2837,23 @@ mysql_execute_command(THD *thd) sp= sp_find(thd, s); if (! sp) { - // QQ Error! - res= -1; + send_error(thd, ER_SP_DOES_NOT_EXIST); + goto error; } else { + // When executing substatements, they're assumed to send_error when + // it happens, but not to send_ok. + my_bool nsok= thd->net.no_send_ok; + + thd->net.no_send_ok= TRUE; res= sp->execute(thd); + thd->net.no_send_ok= nsok; + if (res == 0) send_ok(thd); + else + goto error; // Substatement should already have sent error } } break; @@ -2853,8 +2866,8 @@ mysql_execute_command(THD *thd) sp= sp_find(thd, s); if (! sp) { - // QQ Error! - res= -1; + send_error(thd, ER_SP_DOES_NOT_EXIST); + goto error; } else { @@ -2873,17 +2886,18 @@ mysql_execute_command(THD *thd) sp = sp_find(thd, s); if (! sp) { - // QQ Error! - res= -1; + send_error(thd, ER_SP_DOES_NOT_EXIST); + goto error; } else { String *name = s->const_string(); res= sp_drop(thd, name->c_ptr(), name->length()); - if (res < 0) + if (res != 0) { - // QQ Error! + send_error(thd, ER_SP_DROP_FAILED); + goto error; } send_ok(thd); } @@ -2894,11 +2908,16 @@ mysql_execute_command(THD *thd) break; } thd->proc_info="query end"; // QQ + + // We end up here if res == 0 and send_ok() has been done, + // or res != 0 and no send_error() has yet been done. if (res < 0) send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0); + return res; error: - DBUG_VOID_RETURN; + // We end up here if send_error() has already been done. + return -1; }