summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2005-01-20 10:41:37 +0200
committerunknown <bell@sanja.is.com.ua>2005-01-20 10:41:37 +0200
commitfbd996e6f40926050203fe87482a315b0f2e9b2e (patch)
tree688e14daabde23993878846e8b67af1f4d180abf
parent1d71b90e1a2bca80d0035c1ae711d04348894126 (diff)
downloadmariadb-git-fbd996e6f40926050203fe87482a315b0f2e9b2e.tar.gz
Fixed problem of sending ERROR to client after OK or EOF (BUG#6804)
include/mysql_com.h: Flag which prevent sending error after EOF or OK sent mysql-test/r/kill.result: test of blocking of sending ERROR after OK or EOF mysql-test/t/kill.test: test of blocking of sending ERROR after OK or EOF sql/item_func.cc: typo fixed sql/net_serv.cc: initialization of flag sql/protocol.cc: check and set of flag no_send_error sql/sql_parse.cc: droping flag no_send_error before new command/query execution
-rw-r--r--include/mysql_com.h5
-rw-r--r--mysql-test/r/kill.result12
-rw-r--r--mysql-test/t/kill.test18
-rw-r--r--sql/item_func.cc2
-rw-r--r--sql/net_serv.cc3
-rw-r--r--sql/protocol.cc18
-rw-r--r--sql/sql_parse.cc4
7 files changed, 59 insertions, 3 deletions
diff --git a/include/mysql_com.h b/include/mysql_com.h
index 59b2ee743ec..78d71bde1cf 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -188,6 +188,11 @@ typedef struct st_net {
my_bool no_send_ok; /* For SPs and other things that do multiple stmts */
my_bool no_send_eof; /* For SPs' first version read-only cursors */
/*
+ Set if OK packet is already sent, and we do not need to send error
+ messages
+ */
+ my_bool no_send_error;
+ /*
Pointer to query object in query cache, do not equal NULL (0) for
queries in cache that have not stored its results yet
*/
diff --git a/mysql-test/r/kill.result b/mysql-test/r/kill.result
index 788fab8d31a..f57c134b6d0 100644
--- a/mysql-test/r/kill.result
+++ b/mysql-test/r/kill.result
@@ -9,3 +9,15 @@ select 4;
4
4
drop table t1;
+select get_lock("a", 10);
+get_lock("a", 10)
+1
+ select get_lock("a", 10);
+get_lock("a", 10)
+NULL
+select 1;
+1
+1
+select RELEASE_LOCK("a");
+RELEASE_LOCK("a")
+1
diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test
index 65d4f27059f..ac51482745a 100644
--- a/mysql-test/t/kill.test
+++ b/mysql-test/t/kill.test
@@ -35,3 +35,21 @@ select @id != connection_id();
connection con2;
select 4;
drop table t1;
+
+#
+# test of blocking of sending ERROR after OK or EOF
+#
+connection con1;
+select get_lock("a", 10);
+connection con2;
+let $ID= `select connection_id()`;
+send select get_lock("a", 10);
+connection con1;
+disable_query_log;
+eval kill query $ID;
+enable_query_log;
+connection con2;
+reap;
+select 1;
+connection con1;
+select RELEASE_LOCK("a");
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 434a4741cf3..9d98c5cfa1b 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -3578,7 +3578,7 @@ Item_func_sp::execute(Item **itp)
#endif
/*
- We don't need to surpress senfing of ok packet here (by setting
+ We don't need to surpress sending of ok packet here (by setting
thd->net.no_send_ok to true), because we are not allowing statements
in functions now.
*/
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index bd3bbe3e1a9..2de5853599f 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -121,8 +121,7 @@ my_bool my_net_init(NET *net, Vio* vio)
DBUG_RETURN(1);
net->buff_end=net->buff+net->max_packet;
net->vio = vio;
- net->no_send_ok = 0;
- net->no_send_eof = 0;
+ net->no_send_ok= net->no_send_eof= net->no_send_error= 0;
net->error=0; net->return_errno=0; net->return_status=0;
net->pkt_nr=net->compress_pkt_nr=0;
net->write_pos=net->read_pos = net->buff;
diff --git a/sql/protocol.cc b/sql/protocol.cc
index d537f9cf829..c61a3eb9f7c 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -65,6 +65,12 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
err ? err : net->last_error[0] ?
net->last_error : "NULL"));
+ if (net && net->no_send_error)
+ {
+ thd->clear_error();
+ DBUG_PRINT("info", ("sending error messages prohibited"));
+ DBUG_VOID_RETURN;
+ }
if (thd->spcont && thd->spcont->find_handler(sql_errno,
MYSQL_ERROR::WARN_LEVEL_ERROR))
{
@@ -154,6 +160,13 @@ net_printf_error(THD *thd, uint errcode, ...)
DBUG_ENTER("net_printf_error");
DBUG_PRINT("enter",("message: %u",errcode));
+ if (net && net->no_send_error)
+ {
+ thd->clear_error();
+ DBUG_PRINT("info", ("sending error messages prohibited"));
+ DBUG_VOID_RETURN;
+ }
+
if (thd->spcont && thd->spcont->find_handler(errcode,
MYSQL_ERROR::WARN_LEVEL_ERROR))
{
@@ -300,6 +313,9 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message)
VOID(net_flush(net));
/* We can't anymore send an error to the client */
thd->net.report_error= 0;
+ thd->net.no_send_error= 1;
+ DBUG_PRINT("info", ("OK sent, so no more error sendong allowed"));
+
DBUG_VOID_RETURN;
}
@@ -357,6 +373,8 @@ send_eof(THD *thd, bool no_flush)
if (!no_flush)
VOID(net_flush(net));
}
+ thd->net.no_send_error= 1;
+ DBUG_PRINT("info", ("EOF sent, so no more error sendong allowed"));
}
DBUG_VOID_RETURN;
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 13e7a9c7fab..ecc2d665bde 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -960,6 +960,7 @@ void execute_init_command(THD *thd, sys_var_str *init_command_var,
*/
save_vio= thd->net.vio;
thd->net.vio= 0;
+ thd->net.no_send_error= 0;
dispatch_command(COM_QUERY, thd, thd->query, thd->query_length+1);
rw_unlock(var_mutex);
thd->client_capabilities= save_client_capabilities;
@@ -1019,6 +1020,7 @@ pthread_handler_decl(handle_one_connection,arg)
int error;
NET *net= &thd->net;
thd->thread_stack= (char*) &thd;
+ net->no_send_error= 0;
if ((error=check_connection(thd)))
{ // Wrong permissions
@@ -1057,6 +1059,7 @@ pthread_handler_decl(handle_one_connection,arg)
thd->init_for_queries();
while (!net->error && net->vio != 0 && !(thd->killed == THD::KILL_CONNECTION))
{
+ net->no_send_error= 0;
if (do_command(thd))
break;
}
@@ -2087,6 +2090,7 @@ mysql_execute_command(THD *thd)
/* most outer SELECT_LEX_UNIT of query */
SELECT_LEX_UNIT *unit= &lex->unit;
DBUG_ENTER("mysql_execute_command");
+ thd->net.no_send_error= 0;
/*
In many cases first table of main SELECT_LEX have special meaning =>