diff options
author | Xinchen Hui <laruence@gmail.com> | 2014-04-24 22:43:30 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2014-04-24 22:43:30 +0800 |
commit | 65931501e618125517e740a77bdfd046bd3ca337 (patch) | |
tree | 130fca284dde9d9e28b33803248ec14b662f5896 /ext/pdo_sqlite/sqlite_driver.c | |
parent | e86b287c83894dd869fc94ff710b7f54aceb0970 (diff) | |
download | php-git-65931501e618125517e740a77bdfd046bd3ca337.tar.gz |
Fixed Aggregate
Diffstat (limited to 'ext/pdo_sqlite/sqlite_driver.c')
-rw-r--r-- | ext/pdo_sqlite/sqlite_driver.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c index 24339fa344..25a6c7053e 100644 --- a/ext/pdo_sqlite/sqlite_driver.c +++ b/ext/pdo_sqlite/sqlite_driver.c @@ -317,7 +317,7 @@ static int do_callback(struct pdo_sqlite_fci *fc, zval *cb, int i; int ret; int fake_argc; - zval *agg_context = NULL; + zend_reference *agg_context = NULL; if (is_agg) { is_agg = 2; @@ -336,20 +336,21 @@ static int do_callback(struct pdo_sqlite_fci *fc, zval *cb, /* build up the params */ if (fake_argc) { - zargs = (zval *)safe_emalloc(fake_argc, sizeof(zval), 0); + zargs = safe_emalloc(fake_argc, sizeof(zval), 0); } if (is_agg) { - /* summon the aggregation context */ - /* ???? - agg_context = (zval*)sqlite3_aggregate_context(context, sizeof(zval)); + agg_context = (zend_reference*)sqlite3_aggregate_context(context, sizeof(zend_reference)); if (!agg_context) { - MAKE_STD_ZVAL(*agg_context); - ZVAL_NULL(*agg_context); + ZVAL_NULL(&zargs[0]); + } else { + if (ZVAL_IS_UNDEF(&agg_context->val)) { + GC_REFCOUNT(agg_context) = 1; + GC_TYPE_INFO(agg_context) = IS_REFERENCE; + ZVAL_NULL(&agg_context->val); + } + ZVAL_REF(&zargs[0], agg_context); } - zargs[0] = agg_context; - */ - ZVAL_NULL(&zargs[0]); ZVAL_LONG(&zargs[1], sqlite3_aggregate_count(context)); } @@ -376,10 +377,8 @@ static int do_callback(struct pdo_sqlite_fci *fc, zval *cb, } } - fc->fci.params = zargs; - if ((ret = zend_call_function(&fc->fci, &fc->fcc TSRMLS_CC)) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "An error occurred while invoking the callback"); } @@ -422,20 +421,20 @@ static int do_callback(struct pdo_sqlite_fci *fc, zval *cb, } if (agg_context) { - zval_ptr_dtor(agg_context); + zval_ptr_dtor(&agg_context->val); } } else { /* we're stepping in an aggregate; the return value goes into * the context */ if (agg_context) { - zval_ptr_dtor(agg_context); - }/* ??? - if (retval) { - *agg_context = retval; - retval = NULL; + zval_ptr_dtor(&agg_context->val); + } + if (!ZVAL_IS_UNDEF(&retval)) { + ZVAL_COPY_VALUE(&agg_context->val, &retval); + ZVAL_UNDEF(&retval); } else { - *agg_context = NULL; - }*/ + ZVAL_UNDEF(&agg_context->val); + } } if (!ZVAL_IS_UNDEF(&retval)) { |