cvs: php-src /ext/mysqli mysqli_nonapi.c php_mysqli.h /ext/mysqli/tests bug31668.phpt
| From: | Andrey Hristov | Date: | Wed, 27 Apr 2005 12:12:58 +0000 |
| Subject: | cvs: php-src /ext/mysqli mysqli_nonapi.c php_mysqli.h /ext/mysqli/tests bug31668.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-31620@lists.php.net to get a copy of this message | ||
andrey Wed Apr 27 08:12:58 2005 EDT
Modified files:
/php-src/ext/mysqli mysqli_nonapi.c php_mysqli.h
/php-src/ext/mysqli/tests bug31668.phpt
Log:
MFB (fixing bug 31668)
http://cvs.php.net/diff.php/php-src/ext/mysqli/mysqli_nonapi.c?r1=1.40&r2=1.41&ty=u
Index: php-src/ext/mysqli/mysqli_nonapi.c
diff -u php-src/ext/mysqli/mysqli_nonapi.c:1.40 php-src/ext/mysqli/mysqli_nonapi.c:1.41
--- php-src/ext/mysqli/mysqli_nonapi.c:1.40 Thu Feb 24 18:58:59 2005
+++ php-src/ext/mysqli/mysqli_nonapi.c Wed Apr 27 08:12:58 2005
@@ -15,7 +15,7 @@
| Author: Georg Richter <georg@php.net> |
+----------------------------------------------------------------------+
- $Id: mysqli_nonapi.c,v 1.40 2005/02/24 23:58:59 iliaa Exp $
+ $Id: mysqli_nonapi.c,v 1.41 2005/04/27 12:12:58 andrey Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -67,7 +67,7 @@
}
}
- mysql = (MY_MYSQL *)calloc(1, sizeof(MY_MYSQL));
+ mysql = (MY_MYSQL *) ecalloc(1, sizeof(MY_MYSQL));
if (!(mysql->mysql = mysql_init(NULL))) {
efree(mysql);
http://cvs.php.net/diff.php/php-src/ext/mysqli/php_mysqli.h?r1=1.43&r2=1.44&ty=u
Index: php-src/ext/mysqli/php_mysqli.h
diff -u php-src/ext/mysqli/php_mysqli.h:1.43 php-src/ext/mysqli/php_mysqli.h:1.44
--- php-src/ext/mysqli/php_mysqli.h:1.43 Sun Jan 16 14:28:55 2005
+++ php-src/ext/mysqli/php_mysqli.h Wed Apr 27 08:12:58 2005
@@ -15,7 +15,7 @@
| Author: Georg Richter <georg@php.net> |
+----------------------------------------------------------------------+
- $Id: php_mysqli.h,v 1.43 2005/01/16 19:28:55 zak Exp $
+ $Id: php_mysqli.h,v 1.44 2005/04/27 12:12:58 andrey Exp $
*/
/* A little hack to prevent build break, when mysql is used together with
@@ -57,6 +57,7 @@
MYSQL *mysql;
zval *li_read;
php_stream *li_stream;
+ unsigned int multi_query;
} MY_MYSQL;
typedef struct {
@@ -149,14 +150,14 @@
PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRMLS_DC);
-#define MYSQLI_DISABLE_MQ if (MyG(multi_query)) { \
+#define MYSQLI_DISABLE_MQ if (mysql->multi_query) { \
mysql_set_server_option(mysql->mysql, MYSQL_OPTION_MULTI_STATEMENTS_OFF); \
- MyG(multi_query) = 0; \
+ mysql->multi_query = 0; \
}
-#define MYSQLI_ENABLE_MQ if (!MyG(multi_query)) { \
+#define MYSQLI_ENABLE_MQ if (!mysql->multi_query) { \
mysql_set_server_option(mysql->mysql, MYSQL_OPTION_MULTI_STATEMENTS_ON); \
- MyG(multi_query) = 1; \
+ mysql->multi_query = 1; \
}
#define REGISTER_MYSQLI_CLASS_ENTRY(name, mysqli_entry, class_functions) { \
http://cvs.php.net/diff.php/php-src/ext/mysqli/tests/bug31668.phpt?r1=1.1&r2=1.2&ty=u
Index: php-src/ext/mysqli/tests/bug31668.phpt
diff -u /dev/null php-src/ext/mysqli/tests/bug31668.phpt:1.2
--- /dev/null Wed Apr 27 08:12:58 2005
+++ php-src/ext/mysqli/tests/bug31668.phpt Wed Apr 27 08:12:58 2005
@@ -0,0 +1,56 @@
+--TEST--
+Bug #31668 multi_query works exactly every other time (multi_query was global, now per connection)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+ include "connect.inc";
+
+ $mysql = new mysqli($host, $user, $passwd, "test");
+ $mysql->multi_query('SELECT 1;SELECT 2');
+ do {
+ $res = $mysql->store_result();
+ if ($mysql->errno == 0) {
+ while ($arr = $res->fetch_assoc()) {
+ var_dump($arr);
+ }
+ $res->free();
+ }
+ } while ($mysql->next_result());
+ var_dump($mysql->error, __LINE__);
+ $mysql->close();
+
+ $mysql = new mysqli($host, $user, $passwd, "test");
+ $mysql->multi_query('SELECT 1;SELECT 2');
+ do {
+ $res = $mysql->store_result();
+ if ($mysql->errno == 0) {
+ while ($arr = $res->fetch_assoc()) {
+ var_dump($arr);
+ }
+ $res->free();
+ }
+ } while ($mysql->next_result());
+ var_dump($mysql->error, __LINE__);
+?>
+--EXPECTF--
+array(1) {
+ [1]=>
+ string(1) "1"
+}
+array(1) {
+ [2]=>
+ string(1) "2"
+}
+string(0) ""
+int(%d)
+array(1) {
+ [1]=>
+ string(1) "1"
+}
+array(1) {
+ [2]=>
+ string(1) "2"
+}
+string(0) ""
+int(%d)