georg Sat May 21 04:54:57 2005 EDT Added files: (Branch: PHP_5_0) /php-src/ext/mysqli/tests bug33090.phpt
Modified files: /php-src NEWS /php-src/ext/mysqli php_mysqli.h mysqli_api.c Log: MFH: - fix for bug #33090 (mysqli_prepare doesn't return an error) - mysql_set_charset now works for MySQL >= 5.0.6 http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1760.2.391&r2=1.1760.2.392&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.1760.2.391 php-src/NEWS:1.1760.2.392 --- php-src/NEWS:1.1760.2.391 Fri May 20 10:24:16 2005 +++ php-src/NEWS Sat May 21 04:54:50 2005 @@ -11,6 +11,7 @@ - Fixed ext/mysqli to allocate less memory when fetching bound params of type (MEDIUM|LONG)BLOB/(MEDIUM|LONG)TEXT. (Andrey) - Fixed memory corruption in ImageTTFText() with 64bit systems. (Andrey) +- Fixed bug #33090 (mysqli_prepare doesn't return an error). (Georg) - Fixed bug #33076 (str_ireplace() incorrectly counts result string length and may cause segfault). (Tony) - Fixed bug #33059 (crash when moving xml attribute set in dtd). (Ilia) http://cvs.php.net/diff.php/php-src/ext/mysqli/php_mysqli.h?r1=1.38.2.5&r2=1.38.2.6&ty=u Index: php-src/ext/mysqli/php_mysqli.h diff -u php-src/ext/mysqli/php_mysqli.h:1.38.2.5 php-src/ext/mysqli/php_mysqli.h:1.38.2.6 --- php-src/ext/mysqli/php_mysqli.h:1.38.2.5 Fri May 13 09:53:08 2005 +++ php-src/ext/mysqli/php_mysqli.h Sat May 21 04:54:56 2005 @@ -15,7 +15,7 @@ | Author: Georg Richter <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ - $Id: php_mysqli.h,v 1.38.2.5 2005/05/13 13:53:08 georg Exp $ + $Id: php_mysqli.h,v 1.38.2.6 2005/05/21 08:54:56 georg Exp $ */ /* A little hack to prevent build break, when mysql is used together with @@ -95,7 +95,7 @@ #define PHP_MYSQLI_API #endif -#if MYSQL_VERSION_ID > 40112 && MYSQL_VERSION_ID < 50000 +#if (MYSQL_VERSION_ID > 40112 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID > 50005 #define HAVE_MYSQLI_SET_CHARSET #endif http://cvs.php.net/diff.php/php-src/ext/mysqli/mysqli_api.c?r1=1.87.2.19&r2=1.87.2.20&ty=u Index: php-src/ext/mysqli/mysqli_api.c diff -u php-src/ext/mysqli/mysqli_api.c:1.87.2.19 php-src/ext/mysqli/mysqli_api.c:1.87.2.20 --- php-src/ext/mysqli/mysqli_api.c:1.87.2.19 Mon May 9 18:31:52 2005 +++ php-src/ext/mysqli/mysqli_api.c Sat May 21 04:54:56 2005 @@ -15,7 +15,7 @@ | Author: Georg Richter <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ - $Id: mysqli_api.c,v 1.87.2.19 2005/05/09 22:31:52 andrey Exp $ + $Id: mysqli_api.c,v 1.87.2.20 2005/05/21 08:54:56 georg Exp $ */ #ifdef HAVE_CONFIG_H @@ -1074,7 +1074,7 @@ } /* }}} */ -/* {{{ proto mysqli_set_local_infile_default(object link) +/* {{{ proto void mysqli_set_local_infile_default(object link) unsets user defined handler for load local infile command */ PHP_FUNCTION(mysqli_set_local_infile_default) { @@ -1279,14 +1279,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); } } http://cvs.php.net/co.php/php-src/ext/mysqli/tests/bug33090.phpt?r=1.1&p=1 Index: php-src/ext/mysqli/tests/bug33090.phpt +++ php-src/ext/mysqli/tests/bug33090.phpt --TEST-- Bug #33090 --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php include ("connect.inc"); /*** test mysqli_connect 127.0.0.1 ***/ $link = mysqli_connect($host, $user, $passwd); mysqli_select_db($link, "test"); if (!($link->prepare("this makes no sense"))) { printf("%d\n", $link->errno); printf("%s\n", $link->sqlstate); } $link->close(); ?> --EXPECT-- 1064 42000 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php