Commit 79993565 authored by unknown's avatar unknown

Fixed some basic error handling for SP functions in mysql_execute_command().


include/mysqld_error.h:
  Added error codes for SPs
sql/mysql_priv.h:
  Changed return value of mysql_execute_command() from void to int; need to be able
  to detect if executions of substatements in SPs failed.
sql/share/czech/errmsg.txt:
  Added error messages for SPs.
sql/share/danish/errmsg.txt:
  Added error messages for SPs.
sql/share/dutch/errmsg.txt:
  Added error messages for SPs.
sql/share/english/errmsg.txt:
  Added error messages for SPs.
sql/share/estonian/errmsg.txt:
  Added error messages for SPs.
sql/share/french/errmsg.txt:
  Added error messages for SPs.
sql/share/german/errmsg.txt:
  Added error messages for SPs.
sql/share/greek/errmsg.txt:
  Added error messages for SPs.
sql/share/hungarian/errmsg.txt:
  Added error messages for SPs.
sql/share/italian/errmsg.txt:
  Added error messages for SPs.
sql/share/japanese/errmsg.txt:
  Added error messages for SPs.
sql/share/korean/errmsg.txt:
  Added error messages for SPs.
sql/share/norwegian-ny/errmsg.txt:
  Added error messages for SPs.
sql/share/norwegian/errmsg.txt:
  Added error messages for SPs.
sql/share/polish/errmsg.txt:
  Added error messages for SPs.
sql/share/portuguese/errmsg.txt:
  Added error messages for SPs.
sql/share/romanian/errmsg.txt:
  Added error messages for SPs.
sql/share/russian/errmsg.txt:
  Added error messages for SPs.
sql/share/serbian/errmsg.txt:
  Added error messages for SPs.
sql/share/slovak/errmsg.txt:
  Added error messages for SPs.
sql/share/spanish/errmsg.txt:
  Added error messages for SPs.
sql/share/swedish/errmsg.txt:
  Added error messages for SPs.
sql/share/ukrainian/errmsg.txt:
  Added error messages for SPs.
sql/sp_head.cc:
  Moved net.no_send_ok fiddling to sql_parse.cc.
  Check if mysql_execute_command() failed.
sql/sql_parse.cc:
  Changed return value of mysql_execute_command() from void to int; need to be able
  to detect if executions of substatements in SPs failed. Fixed all returns
  accordingly.
  Added error checks for SQLCOM_CREATE_PROCEDURE, CALL, ALTER_PROCEDURE, and
  DROP_PROCEDURE.
parent bc543f69
...@@ -266,4 +266,8 @@ ...@@ -266,4 +266,8 @@
#define ER_SELECT_REDUCED 1247 #define ER_SELECT_REDUCED 1247
#define ER_TABLENAME_NOT_ALLOWED_HERE 1248 #define ER_TABLENAME_NOT_ALLOWED_HERE 1248
#define ER_NOT_SUPPORTED_AUTH_MODE 1249 #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
...@@ -349,7 +349,7 @@ extern "C" pthread_handler_decl(handle_one_connection,arg); ...@@ -349,7 +349,7 @@ extern "C" pthread_handler_decl(handle_one_connection,arg);
extern "C" pthread_handler_decl(handle_bootstrap,arg); extern "C" pthread_handler_decl(handle_bootstrap,arg);
void end_thread(THD *thd,bool put_in_cache); void end_thread(THD *thd,bool put_in_cache);
void flush_thread_cache(); void flush_thread_cache();
void mysql_execute_command(THD *thd); int mysql_execute_command(THD *thd);
bool do_command(THD *thd); bool do_command(THD *thd);
bool dispatch_command(enum enum_server_command command, THD *thd, bool dispatch_command(enum enum_server_command command, THD *thd,
char* packet, uint packet_length); char* packet, uint packet_length);
......
...@@ -260,3 +260,7 @@ v/* ...@@ -260,3 +260,7 @@ v/*
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -254,3 +254,7 @@ ...@@ -254,3 +254,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -262,3 +262,7 @@ ...@@ -262,3 +262,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -251,3 +251,8 @@ ...@@ -251,3 +251,8 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -256,3 +256,7 @@ ...@@ -256,3 +256,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -251,3 +251,7 @@ ...@@ -251,3 +251,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -261,3 +261,7 @@ ...@@ -261,3 +261,7 @@
"Select %u wurde während der Optimierung reduziert.", "Select %u wurde während der Optimierung reduziert.",
"Tabelle '%-.64s', die in einem der SELECT-Befehle verwendet wurde kann nicht in %-.32s verwendet werden." "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" "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"
...@@ -251,3 +251,7 @@ ...@@ -251,3 +251,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -253,3 +253,7 @@ ...@@ -253,3 +253,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -251,3 +251,7 @@ ...@@ -251,3 +251,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -253,3 +253,7 @@ ...@@ -253,3 +253,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -251,3 +251,7 @@ ...@@ -251,3 +251,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -253,3 +253,7 @@ ...@@ -253,3 +253,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -253,3 +253,7 @@ ...@@ -253,3 +253,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -255,3 +255,7 @@ ...@@ -255,3 +255,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -251,3 +251,7 @@ ...@@ -251,3 +251,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -255,3 +255,7 @@ ...@@ -255,3 +255,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -254,3 +254,7 @@ ...@@ -254,3 +254,7 @@
"Select %u ", "Select %u ",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -247,3 +247,7 @@ ...@@ -247,3 +247,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -259,3 +259,7 @@ ...@@ -259,3 +259,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -252,3 +252,7 @@ ...@@ -252,3 +252,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -251,3 +251,7 @@ ...@@ -251,3 +251,7 @@
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -256,3 +256,7 @@ ...@@ -256,3 +256,7 @@
"Select %u was iii", "Select %u was iii",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s" "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" "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"
...@@ -157,9 +157,6 @@ sp_head::execute(THD *thd) ...@@ -157,9 +157,6 @@ sp_head::execute(THD *thd)
{ // Execute instructions... { // Execute instructions...
uint ip= 0; 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) while (ret == 0)
{ {
...@@ -170,8 +167,6 @@ sp_head::execute(THD *thd) ...@@ -170,8 +167,6 @@ sp_head::execute(THD *thd)
break; break;
ret= i->execute(thd, &ip); ret= i->execute(thd, &ip);
} }
thd->net.no_send_ok= nsok;
} }
// Don't copy back OUT values if we got an error // Don't copy back OUT values if we got an error
...@@ -323,18 +318,19 @@ int ...@@ -323,18 +318,19 @@ int
sp_instr_stmt::execute(THD *thd, uint *nextp) sp_instr_stmt::execute(THD *thd, uint *nextp)
{ {
LEX olex; // The other lex LEX olex; // The other lex
int res;
memcpy(&olex, &thd->lex, sizeof(LEX)); // Save the other lex memcpy(&olex, &thd->lex, sizeof(LEX)); // Save the other lex
memcpy(&thd->lex, &m_lex, sizeof(LEX)); // Use my own lex memcpy(&thd->lex, &m_lex, sizeof(LEX)); // Use my own lex
thd->lex.thd = thd; thd->lex.thd = thd;
mysql_execute_command(thd); res= mysql_execute_command(thd);
memcpy(&thd->lex, &olex, sizeof(LEX)); // Restore the other lex memcpy(&thd->lex, &olex, sizeof(LEX)); // Restore the other lex
*nextp = m_ip+1; *nextp = m_ip+1;
return 0; return res;
} }
// //
......
...@@ -1482,7 +1482,7 @@ bool alloc_query(THD *thd, char *packet, ulong packet_length) ...@@ -1482,7 +1482,7 @@ bool alloc_query(THD *thd, char *packet, ulong packet_length)
** Execute command saved in thd and current_lex->sql_command ** Execute command saved in thd and current_lex->sql_command
****************************************************************************/ ****************************************************************************/
void int
mysql_execute_command(THD *thd) mysql_execute_command(THD *thd)
{ {
int res= 0; int res= 0;
...@@ -1513,7 +1513,7 @@ mysql_execute_command(THD *thd) ...@@ -1513,7 +1513,7 @@ mysql_execute_command(THD *thd)
given and the table list says the query should not be replicated given and the table list says the query should not be replicated
*/ */
if (table_rules_on && tables && !tables_ok(thd,tables)) if (table_rules_on && tables && !tables_ok(thd,tables))
DBUG_VOID_RETURN; return 0;
#ifndef TO_BE_DELETED #ifndef TO_BE_DELETED
/* /*
This is a workaround to deal with the shortcoming in 3.23.44-3.23.46 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) ...@@ -1549,7 +1549,7 @@ mysql_execute_command(THD *thd)
{ {
if (res < 0 || thd->net.report_error) if (res < 0 || thd->net.report_error)
send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0); send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0);
DBUG_VOID_RETURN; return res;
} }
} }
} }
...@@ -1558,7 +1558,7 @@ mysql_execute_command(THD *thd) ...@@ -1558,7 +1558,7 @@ mysql_execute_command(THD *thd)
lex->unit.create_total_list(thd, lex, &tables)) || lex->unit.create_total_list(thd, lex, &tables)) ||
(table_rules_on && tables && thd->slave_thread && (table_rules_on && tables && thd->slave_thread &&
!tables_ok(thd,tables))) !tables_ok(thd,tables)))
DBUG_VOID_RETURN; return 0;
statistic_increment(com_stat[lex->sql_command],&LOCK_status); statistic_increment(com_stat[lex->sql_command],&LOCK_status);
switch (lex->sql_command) { switch (lex->sql_command) {
...@@ -1597,7 +1597,7 @@ mysql_execute_command(THD *thd) ...@@ -1597,7 +1597,7 @@ mysql_execute_command(THD *thd)
if (!(result= new select_send())) if (!(result= new select_send()))
{ {
send_error(thd, ER_OUT_OF_RESOURCES); send_error(thd, ER_OUT_OF_RESOURCES);
DBUG_VOID_RETURN; goto error;
} }
else else
thd->send_explain_fields(result); thd->send_explain_fields(result);
...@@ -1838,7 +1838,7 @@ mysql_execute_command(THD *thd) ...@@ -1838,7 +1838,7 @@ mysql_execute_command(THD *thd)
find_real_table_in_list(tables->next, tables->db, tables->real_name)) find_real_table_in_list(tables->next, tables->db, tables->real_name))
{ {
net_printf(thd,ER_UPDATE_TABLE_USED,tables->real_name); net_printf(thd,ER_UPDATE_TABLE_USED,tables->real_name);
DBUG_VOID_RETURN; return -1;
} }
if (tables->next) if (tables->next)
{ {
...@@ -1918,7 +1918,7 @@ mysql_execute_command(THD *thd) ...@@ -1918,7 +1918,7 @@ mysql_execute_command(THD *thd)
if (thd->locked_tables || thd->active_transaction()) if (thd->locked_tables || thd->active_transaction())
{ {
send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION); send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION);
break; goto error;
} }
{ {
LOCK_ACTIVE_MI; LOCK_ACTIVE_MI;
...@@ -1929,7 +1929,7 @@ mysql_execute_command(THD *thd) ...@@ -1929,7 +1929,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_ALTER_TABLE: case SQLCOM_ALTER_TABLE:
#if defined(DONT_ALLOW_SHOW_COMMANDS) #if defined(DONT_ALLOW_SHOW_COMMANDS)
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
break; goto error;
#else #else
{ {
ulong priv=0; ulong priv=0;
...@@ -2019,7 +2019,7 @@ mysql_execute_command(THD *thd) ...@@ -2019,7 +2019,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_BINLOGS: case SQLCOM_SHOW_BINLOGS:
#ifdef DONT_ALLOW_SHOW_COMMANDS #ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
DBUG_VOID_RETURN; goto error;
#else #else
{ {
if (check_global_access(thd, SUPER_ACL)) if (check_global_access(thd, SUPER_ACL))
...@@ -2031,7 +2031,7 @@ mysql_execute_command(THD *thd) ...@@ -2031,7 +2031,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_CREATE: case SQLCOM_SHOW_CREATE:
#ifdef DONT_ALLOW_SHOW_COMMANDS #ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
DBUG_VOID_RETURN; goto error;
#else #else
{ {
if (check_db_used(thd, tables) || if (check_db_used(thd, tables) ||
...@@ -2103,7 +2103,7 @@ mysql_execute_command(THD *thd) ...@@ -2103,7 +2103,7 @@ mysql_execute_command(THD *thd)
if (select_lex->item_list.elements != lex->value_list.elements) if (select_lex->item_list.elements != lex->value_list.elements)
{ {
send_error(thd,ER_WRONG_VALUE_COUNT); send_error(thd,ER_WRONG_VALUE_COUNT);
DBUG_VOID_RETURN; goto error;
} }
res= mysql_update(thd,tables, res= mysql_update(thd,tables,
select_lex->item_list, select_lex->item_list,
...@@ -2123,7 +2123,7 @@ mysql_execute_command(THD *thd) ...@@ -2123,7 +2123,7 @@ mysql_execute_command(THD *thd)
if (select_lex->item_list.elements != lex->value_list.elements) if (select_lex->item_list.elements != lex->value_list.elements)
{ {
send_error(thd,ER_WRONG_VALUE_COUNT); send_error(thd,ER_WRONG_VALUE_COUNT);
DBUG_VOID_RETURN; goto error;
} }
{ {
const char *msg= 0; const char *msg= 0;
...@@ -2159,7 +2159,7 @@ mysql_execute_command(THD *thd) ...@@ -2159,7 +2159,7 @@ mysql_execute_command(THD *thd)
if (select_lex->item_list.elements != lex->value_list.elements) if (select_lex->item_list.elements != lex->value_list.elements)
{ {
send_error(thd,ER_WRONG_VALUE_COUNT); send_error(thd,ER_WRONG_VALUE_COUNT);
DBUG_VOID_RETURN; goto error;
} }
res = mysql_insert(thd,tables,lex->field_list,lex->many_values, res = mysql_insert(thd,tables,lex->field_list,lex->many_values,
select_lex->item_list, lex->value_list, select_lex->item_list, lex->value_list,
...@@ -2199,7 +2199,7 @@ mysql_execute_command(THD *thd) ...@@ -2199,7 +2199,7 @@ mysql_execute_command(THD *thd)
if (find_real_table_in_list(tables->next, tables->db, tables->real_name)) if (find_real_table_in_list(tables->next, tables->db, tables->real_name))
{ {
net_printf(thd,ER_UPDATE_TABLE_USED,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 */ /* Skip first table, which is the table we are inserting in */
...@@ -2357,7 +2357,7 @@ mysql_execute_command(THD *thd) ...@@ -2357,7 +2357,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_DATABASES: case SQLCOM_SHOW_DATABASES:
#if defined(DONT_ALLOW_SHOW_COMMANDS) #if defined(DONT_ALLOW_SHOW_COMMANDS)
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
DBUG_VOID_RETURN; goto error;
#else #else
if ((specialflag & SPECIAL_SKIP_SHOW_DB) && if ((specialflag & SPECIAL_SKIP_SHOW_DB) &&
check_global_access(thd, SHOW_DB_ACL)) check_global_access(thd, SHOW_DB_ACL))
...@@ -2391,7 +2391,7 @@ mysql_execute_command(THD *thd) ...@@ -2391,7 +2391,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_LOGS: case SQLCOM_SHOW_LOGS:
#ifdef DONT_ALLOW_SHOW_COMMANDS #ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
DBUG_VOID_RETURN; goto error;
#else #else
{ {
if (grant_option && check_access(thd, FILE_ACL, any_db)) if (grant_option && check_access(thd, FILE_ACL, any_db))
...@@ -2404,7 +2404,7 @@ mysql_execute_command(THD *thd) ...@@ -2404,7 +2404,7 @@ mysql_execute_command(THD *thd)
/* FALL THROUGH */ /* FALL THROUGH */
#ifdef DONT_ALLOW_SHOW_COMMANDS #ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
DBUG_VOID_RETURN; goto error;
#else #else
{ {
char *db=select_lex->db ? select_lex->db : thd->db; char *db=select_lex->db ? select_lex->db : thd->db;
...@@ -2440,7 +2440,7 @@ mysql_execute_command(THD *thd) ...@@ -2440,7 +2440,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_FIELDS: case SQLCOM_SHOW_FIELDS:
#ifdef DONT_ALLOW_SHOW_COMMANDS #ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
DBUG_VOID_RETURN; goto error;
#else #else
{ {
char *db=tables->db; char *db=tables->db;
...@@ -2465,7 +2465,7 @@ mysql_execute_command(THD *thd) ...@@ -2465,7 +2465,7 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_KEYS: case SQLCOM_SHOW_KEYS:
#ifdef DONT_ALLOW_SHOW_COMMANDS #ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
DBUG_VOID_RETURN; goto error;
#else #else
{ {
char *db=tables->db; char *db=tables->db;
...@@ -2813,13 +2813,17 @@ mysql_execute_command(THD *thd) ...@@ -2813,13 +2813,17 @@ mysql_execute_command(THD *thd)
break; break;
case SQLCOM_CREATE_PROCEDURE: case SQLCOM_CREATE_PROCEDURE:
if (!lex->sphead) if (!lex->sphead)
res= -1; {
send_error(thd, ER_SP_NO_RECURSIVE_CREATE);
goto error;
}
else else
{ {
res= lex->sphead->create(thd); 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); send_ok(thd);
} }
...@@ -2833,14 +2837,23 @@ mysql_execute_command(THD *thd) ...@@ -2833,14 +2837,23 @@ mysql_execute_command(THD *thd)
sp= sp_find(thd, s); sp= sp_find(thd, s);
if (! sp) if (! sp)
{ {
// QQ Error! send_error(thd, ER_SP_DOES_NOT_EXIST);
res= -1; goto error;
} }
else 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); res= sp->execute(thd);
thd->net.no_send_ok= nsok;
if (res == 0) if (res == 0)
send_ok(thd); send_ok(thd);
else
goto error; // Substatement should already have sent error
} }
} }
break; break;
...@@ -2853,8 +2866,8 @@ mysql_execute_command(THD *thd) ...@@ -2853,8 +2866,8 @@ mysql_execute_command(THD *thd)
sp= sp_find(thd, s); sp= sp_find(thd, s);
if (! sp) if (! sp)
{ {
// QQ Error! send_error(thd, ER_SP_DOES_NOT_EXIST);
res= -1; goto error;
} }
else else
{ {
...@@ -2873,17 +2886,18 @@ mysql_execute_command(THD *thd) ...@@ -2873,17 +2886,18 @@ mysql_execute_command(THD *thd)
sp = sp_find(thd, s); sp = sp_find(thd, s);
if (! sp) if (! sp)
{ {
// QQ Error! send_error(thd, ER_SP_DOES_NOT_EXIST);
res= -1; goto error;
} }
else else
{ {
String *name = s->const_string(); String *name = s->const_string();
res= sp_drop(thd, name->c_ptr(), name->length()); 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); send_ok(thd);
} }
...@@ -2894,11 +2908,16 @@ mysql_execute_command(THD *thd) ...@@ -2894,11 +2908,16 @@ mysql_execute_command(THD *thd)
break; break;
} }
thd->proc_info="query end"; // QQ 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) if (res < 0)
send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0); send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0);
return res;
error: error:
DBUG_VOID_RETURN; // We end up here if send_error() has already been done.
return -1;
} }
......
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