From c057b3f63d58d1f1cdf7a0bd654ef9a55b26bd2a Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Sun, 11 May 2014 19:37:48 +0800 Subject: [PATCH] Finish refactoring of MySQLi a few tests failed due to knew issue, I will disscuss with dmitry later --- ext/mysqli/mysqli_api.c | 34 +++++++++---------- .../tests/mysqli_result_references.phpt | 30 ++++++++-------- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 59d03e6579..6c38cfff44 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -866,24 +866,6 @@ PHP_FUNCTION(mysqli_error) } /* }}} */ -#if 0 -#ifndef MYSQLI_USE_MYSQLND -/* {{{ php_mysqli_stmt_copy_it */ -static void -php_mysqli_stmt_copy_it(zval *copies, zval *original, uint param_count, uint current) -{ - if (!*copies) { - *copies = ecalloc(param_count, sizeof(zval *)); - } - MAKE_STD_ZVAL((*copies)[current]); - *(*copies)[current] = *original; - Z_SET_REFCOUNT_P((*copies)[current], 1); - zval_copy_ctor((*copies)[current]); -} -/* }}} */ -#endif -#endif - /* {{{ proto bool mysqli_stmt_execute(object stmt) Execute a prepared statement */ PHP_FUNCTION(mysqli_stmt_execute) @@ -900,6 +882,22 @@ PHP_FUNCTION(mysqli_stmt_execute) MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID); #ifndef MYSQLI_USE_MYSQLND + if (stmt->param.var_cnt) { + int j; + for (i = 0; i < stmt->param.var_cnt; i++) { + if (!Z_ISREF(stmt->param.vars[i])) { + continue; + } + for (j = i + 1; j < stmt->param.var_cnt; j++) { + /* Oops, someone binding the same variable - clone */ + if (Z_TYPE(stmt->param.vars[j]) == Z_TYPE(stmt->param.vars[i]) && + Z_REFVAL(stmt->param.vars[j]) == Z_REFVAL(stmt->param.vars[i])) { + SEPARATE_ZVAL(&stmt->param.vars[j]); + break; + } + } + } + } for (i = 0; i < stmt->param.var_cnt; i++) { if (!Z_ISUNDEF(stmt->param.vars[i])) { zval *param; diff --git a/ext/mysqli/tests/mysqli_result_references.phpt b/ext/mysqli/tests/mysqli_result_references.phpt index b6bce0d981..9b5d476ac4 100644 --- a/ext/mysqli/tests/mysqli_result_references.phpt +++ b/ext/mysqli/tests/mysqli_result_references.phpt @@ -85,61 +85,61 @@ array(7) refcount(2){ [0]=> array(2) refcount(1){ [%u|b%"id"]=> - long(1) refcount(1) + long(1) [%u|b%"label"]=> %unicode|string%(1) "a" refcount(1) } [1]=> array(2) refcount(1){ [%u|b%"id"]=> - long(2) refcount(1) + long(2) [%u|b%"label"]=> %unicode|string%(1) "b" refcount(1) } [2]=> array(2) refcount(1){ [%u|b%"id"]=> - long(1) refcount(1) + long(1) [%u|b%"label"]=> %unicode|string%(1) "a" refcount(1) } [3]=> array(2) refcount(1){ [%u|b%"id"]=> - long(2) refcount(1) + long(2) [%u|b%"label"]=> %unicode|string%(1) "b" refcount(1) } [4]=> array(3) refcount(1){ [%u|b%"id"]=> - &long(3) refcount(2) + &long(3) [%u|b%"label"]=> %unicode|string%(1) "a" refcount(1) [%u|b%"id2"]=> - &long(3) refcount(2) + &long(3) } [5]=> array(3) refcount(1){ [%u|b%"id"]=> - &long(4) refcount(2) + &long(4) [%u|b%"label"]=> %unicode|string%(1) "b" refcount(1) [%u|b%"id2"]=> - &long(4) refcount(2) + &long(4) } [6]=> - &object(mysqli_result)#2 (5) refcount(2){ + &object(mysqli_result)#%d (5) refcount(%d){ [%u|b%"current_field"]=> - NULL refcount(1) + NULL [%u|b%"field_count"]=> - NULL refcount(1) + NULL [%u|b%"lengths"]=> - NULL refcount(1) + NULL [%u|b%"num_rows"]=> - NULL refcount(1) + NULL [%u|b%"type"]=> - NULL refcount(1) + NULL } } array(1) refcount(2){ @@ -151,4 +151,4 @@ array(1) refcount(2){ %unicode|string%(1) "a" refcount(1) } } -done! \ No newline at end of file +done! -- 2.40.0