Your message dated Fri, 28 Jul 2006 00:30:54 +0200
with message-id <[EMAIL PROTECTED]>
and subject line libmysqlclient10: does not report all reconnection errors
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
Package: libmysqlclient10
Version: 3.23.56-2
Severity: normal


I found this problem while using the python bindings which set
autocommit off by default.

When not in autocommit mode (SET AUTOCOMMIT=0) the client will fail on
reconnect and the nature of the error is not reported to the user.

In the program below the final mysql_real_query() correctly returns
-1 but mysql_error() incorrectly returns an empty string.

----

#include <unistd.h>
#include <stdio.h>
#include <mysql.h>
#include <string.h>

int main()
{
    int rtn;
    char * query = "show tables";
    char * autocommit = "SET AUTOCOMMIT=0";

    MYSQL conn;
    MYSQL* r = mysql_init(&conn);

    printf("init done %p\n", r);

    r = mysql_real_connect(&conn, "localhost", "airplay", "airplay", "Airplay", 
0, NULL, 0);

    printf("connect done %p\n", r);

    rtn = mysql_real_query(&conn, autocommit, strlen(autocommit));
    printf("query returned %d '%s'\n", rtn, mysql_error(&conn));

    rtn = mysql_real_query(&conn, query, strlen(query));
    printf("query returned %d '%s'\n", rtn, mysql_error(&conn));
    MYSQL_RES *res = mysql_use_result(&conn);
    mysql_free_result(res);

    sleep(7);
    rtn = mysql_real_query(&conn, query, strlen(query));
    printf("query returned %d '%s'\n", rtn, mysql_error(&conn));
    res = mysql_use_result(&conn);
    mysql_free_result(res);
    return 0;
}

----

The following patch seemed to fix this for me:

--- libmysql.c  2003-04-13 18:41:40.000000000 +0100
+++ libmysql.new        2005-03-02 15:45:54.000000000 +0000
@@ -470,7 +470,11 @@
     }
     end_server(mysql);
     if (mysql_reconnect(mysql))
+    {
+      net->last_errno=CR_SERVER_GONE_ERROR;
+      strmov(net->last_error,ER(net->last_errno));
       goto end;
+    }
     if (net_write_command(net,(uchar) command,arg,
                          length ? length : (ulong) strlen(arg)))
     {

-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (990, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.11-rc5
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)

Versions of packages libmysqlclient10 depends on:
ii  libc6                       2.3.2.ds1-20 GNU C Library: Shared libraries an
ii  mysql-common                4.0.23-7     mysql database common files (e.g. 
ii  zlib1g                      1:1.2.2-4    compression library - runtime

-- no debconf information


--- End Message ---
--- Begin Message ---
I'm closing this bug which has been fixed in the latest mysql versions.

bye,

-christian-


--- End Message ---

Reply via email to