summaryrefslogtreecommitdiff
path: root/libmysql/libmysql.c
diff options
context:
space:
mode:
authorkonstantin@mysql.com <>2005-02-10 17:41:54 +0300
committerkonstantin@mysql.com <>2005-02-10 17:41:54 +0300
commit4b2b327dccfb2acc2903d83a5611045987e47183 (patch)
tree224dc4a8c83b72b4b336a3b9892867b921d97505 /libmysql/libmysql.c
parent016544df2276f3bb0471e3638416c1ecc378c710 (diff)
downloadmariadb-git-4b2b327dccfb2acc2903d83a5611045987e47183.tar.gz
A fix and test case for Bug#7990 "mysql_stmt_close doesn't
reset mysql->net.last_error": the solution is to clear MYSQL->net error before performing COM_CLOSE: if the call succeeds, the connection is usable for other statements. More comprehensive fix is to clear MYSQL->net for all recoverable errors at the time they happen, it will be implemented in 5.0 as it introduces incompatibility in behavior.
Diffstat (limited to 'libmysql/libmysql.c')
-rw-r--r--libmysql/libmysql.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 24a7fa5f929..76cf5c3913c 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1788,6 +1788,18 @@ static my_bool my_realloc_str(NET *net, ulong length)
}
+/* Clear possible error statee of struct NET */
+
+static void net_clear_error(NET *net)
+{
+ if (net->last_errno)
+ {
+ net->last_errno= 0;
+ net->last_error[0]= '\0';
+ strmov(net->sqlstate, not_error_sqlstate);
+ }
+}
+
/*
Set statement error code, sqlstate, and error message
from given errcode and sqlstate.
@@ -4512,6 +4524,11 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
if (mysql->unbuffered_fetch_owner == &stmt->unbuffered_fetch_cancelled)
mysql->unbuffered_fetch_owner= 0;
+ /*
+ Clear NET error state: if the following commands come through
+ successfully, connection will still be usable for other commands.
+ */
+ net_clear_error(&mysql->net);
if (mysql->status != MYSQL_STATUS_READY)
{
/*