georg Sat May 21 04:38:56 2005 EDT
Modified files:
/php-src/ext/mysqli mysqli_api.c
Log:
fix for bug #33090 (mysql_prepare doesn't return error)
http://cvs.php.net/diff.php/php-src/ext/mysqli/mysqli_api.c?r1=1.115&r2=1.116&ty=u
Index: php-src/ext/mysqli/mysqli_api.c
diff -u php-src/ext/mysqli/mysqli_api.c:1.115
php-src/ext/mysqli/mysqli_api.c:1.116
--- php-src/ext/mysqli/mysqli_api.c:1.115 Mon May 9 18:29:54 2005
+++ php-src/ext/mysqli/mysqli_api.c Sat May 21 04:38:53 2005
@@ -15,7 +15,7 @@
| Author: Georg Richter <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
- $Id: mysqli_api.c,v 1.115 2005/05/09 22:29:54 andrey Exp $
+ $Id: mysqli_api.c,v 1.116 2005/05/21 08:38:53 georg Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -1278,14 +1278,22 @@
if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) {
if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
- if (stmt->stmt->last_errno) {
- /* if we close the statement handle, we have to
copy the errors to connection handle */
- mysql->mysql->net.last_errno =
stmt->stmt->last_errno;
- strcpy(mysql->mysql->net.last_error,
stmt->stmt->last_error);
- strcpy(mysql->mysql->net.sqlstate,
stmt->stmt->sqlstate);
- }
+ char last_error[MYSQL_ERRMSG_SIZE];
+ char sqlstate[SQLSTATE_LENGTH+1];
+ unsigned int last_errno;
+
+ /* mysql_stmt_close clears errors, so we have to store
them temporarily */
+ last_errno = stmt->stmt->last_errno;
+ memcpy(last_error, stmt->stmt->last_error,
MYSQL_ERRMSG_SIZE);
+ memcpy(sqlstate, mysql->mysql->net.sqlstate,
SQLSTATE_LENGTH+1);
+
mysql_stmt_close(stmt->stmt);
stmt->stmt = NULL;
+
+ /* restore error messages */
+ mysql->mysql->net.last_errno = last_errno;
+ memcpy(mysql->mysql->net.last_error, last_error,
MYSQL_ERRMSG_SIZE);
+ memcpy(mysql->mysql->net.sqlstate, sqlstate,
SQLSTATE_LENGTH+1);
}
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php