From: <da...@br...> - 2002-12-20 05:53:41
|
Update of /home/cvs/libdbi/drivers/mysql In directory backbeat:/tmp/cvs-serv4304/drivers/mysql Modified Files: dbd_mysql.c Log Message: fixed and enhanced error handling when dbi_conn_connect failed Index: dbd_mysql.c =================================================================== RCS file: /home/cvs/libdbi/drivers/mysql/dbd_mysql.c,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- dbd_mysql.c 3 Dec 2002 08:25:31 -0000 1.59 +++ dbd_mysql.c 20 Dec 2002 05:53:07 -0000 1.60 @@ -44,7 +44,7 @@ static const dbi_info_t driver_info = { "mysql", - "MySQL database support (using libmysqlclient6)", + "MySQL database support (using libmysqlclient)", "Mark M. Tobenkin <ma...@br...>", "http://libdbi.sourceforge.net", "dbd_mysql v" VERSION, @@ -90,9 +90,15 @@ int _compression = (compression > 0) ? CLIENT_COMPRESS : 0; mycon = mysql_init(NULL); - if (!mycon || !mysql_real_connect(mycon , host, username, password, dbname, port, unix_socket, _compression)) { - mysql_close(mycon); + if (!mycon) { return -1; + } + else if (!mysql_real_connect(mycon, host, username, password, dbname, port, unix_socket, _compression)) { + conn->connection = (void *)mycon; // still need this set so _error_handler can grab information + _error_handler(conn, DBI_ERROR_DBD); + mysql_close(mycon); + conn->connection = NULL; // myconn no longer valid + return -2; } else { conn->connection = (void *)mycon; |