scottmac                Wed Dec 24 19:21:42 2008 UTC

  Modified files:              
    /php-src/ext/sqlite3        php_sqlite3_structs.h sqlite3.c 
    /php-src/ext/sqlite3/tests  sqlite3_25_create_aggregate.phpt 
  Log:
  Stop using sqlite3_aggregate_count() as this is now deprecated.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/php_sqlite3_structs.h?r1=1.4&r2=1.5&diff_format=u
Index: php-src/ext/sqlite3/php_sqlite3_structs.h
diff -u php-src/ext/sqlite3/php_sqlite3_structs.h:1.4 
php-src/ext/sqlite3/php_sqlite3_structs.h:1.5
--- php-src/ext/sqlite3/php_sqlite3_structs.h:1.4       Fri Aug  1 08:27:46 2008
+++ php-src/ext/sqlite3/php_sqlite3_structs.h   Wed Dec 24 19:21:42 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_sqlite3_structs.h,v 1.4 2008/08/01 08:27:46 tony2001 Exp $ */
+/* $Id: php_sqlite3_structs.h,v 1.5 2008/12/24 19:21:42 scottmac Exp $ */
 
 #ifndef PHP_SQLITE_STRUCTS_H
 #define PHP_SQLITE_STRUCTS_H
@@ -72,6 +72,12 @@
        zend_llist free_list;
 } php_sqlite3_db_object;
 
+/* Structure for SQLite Database object. */
+typedef struct _php_sqlite3_agg_context  {
+       zval *zval_context;
+       long row_count;
+} php_sqlite3_agg_context;
+
 typedef struct _php_sqlite3_stmt_object php_sqlite3_stmt;
 typedef struct _php_sqlite3_result_object php_sqlite3_result;
 
http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.23&r2=1.24&diff_format=u
Index: php-src/ext/sqlite3/sqlite3.c
diff -u php-src/ext/sqlite3/sqlite3.c:1.23 php-src/ext/sqlite3/sqlite3.c:1.24
--- php-src/ext/sqlite3/sqlite3.c:1.23  Fri Nov 28 15:36:34 2008
+++ php-src/ext/sqlite3/sqlite3.c       Wed Dec 24 19:21:42 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: sqlite3.c,v 1.23 2008/11/28 15:36:34 felipe Exp $ */
+/* $Id: sqlite3.c,v 1.24 2008/12/24 19:21:42 scottmac Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -619,7 +619,7 @@
        int i;
        int ret;
        int fake_argc;
-       zval **agg_context = NULL;
+       php_sqlite3_agg_context *agg_context = NULL;
 
        if (is_agg) {
                is_agg = 2;
@@ -643,16 +643,17 @@
 
        if (is_agg) {
                /* summon the aggregation context */
-               agg_context = (zval**)sqlite3_aggregate_context(context, 
sizeof(zval*));
-               if (!*agg_context) {
-                       MAKE_STD_ZVAL(*agg_context);
-                       ZVAL_NULL(*agg_context);
+               agg_context = (php_sqlite3_agg_context 
*)sqlite3_aggregate_context(context, sizeof(php_sqlite3_agg_context));
+
+               if (!agg_context->zval_context) {
+                       MAKE_STD_ZVAL(agg_context->zval_context);
+                       ZVAL_NULL(agg_context->zval_context);
                }
-               zargs[0] = agg_context;
+               zargs[0] = &agg_context->zval_context;
 
                zargs[1] = emalloc(sizeof(zval*));
                MAKE_STD_ZVAL(*zargs[1]);
-               ZVAL_LONG(*zargs[1], sqlite3_aggregate_count(context));
+               ZVAL_LONG(*zargs[1], agg_context->row_count);
        }
 
        for (i = 0; i < argc; i++) {
@@ -727,20 +728,20 @@
                        sqlite3_result_error(context, "failed to invoke 
callback", 0);
                }
 
-               if (agg_context) {
-                       zval_ptr_dtor(agg_context);
+               if (agg_context && agg_context->zval_context) {
+                       zval_ptr_dtor(&agg_context->zval_context);
                }
        } else {
                /* we're stepping in an aggregate; the return value goes into
                 * the context */
-               if (agg_context) {
-                       zval_ptr_dtor(agg_context);
+               if (agg_context && agg_context->zval_context) {
+                       zval_ptr_dtor(&agg_context->zval_context);
                }
                if (retval) {
-                       *agg_context = retval;
+                       agg_context->zval_context = retval;
                        retval = NULL;
                } else {
-                       *agg_context = NULL;
+                       agg_context->zval_context = NULL;
                }
        }
 
@@ -763,7 +764,10 @@
 static void php_sqlite3_callback_step(sqlite3_context *context, int argc, 
sqlite3_value **argv) /* {{{ */
 {
        php_sqlite3_func *func = (php_sqlite3_func *)sqlite3_user_data(context);
+       php_sqlite3_agg_context *agg_context = (php_sqlite3_agg_context 
*)sqlite3_aggregate_context(context, sizeof(php_sqlite3_agg_context));
+
        TSRMLS_FETCH();
+       agg_context->row_count++;
 
        sqlite3_do_callback(&func->astep, func->step, argc, argv, context, 1 
TSRMLS_CC);
 }
@@ -772,7 +776,10 @@
 static void php_sqlite3_callback_final(sqlite3_context *context) /* {{{ */
 {
        php_sqlite3_func *func = (php_sqlite3_func *)sqlite3_user_data(context);
+       php_sqlite3_agg_context *agg_context = (php_sqlite3_agg_context 
*)sqlite3_aggregate_context(context, sizeof(php_sqlite3_agg_context));
+
        TSRMLS_FETCH();
+       agg_context->row_count = 0;
 
        sqlite3_do_callback(&func->afini, func->fini, 0, NULL, context, 1 
TSRMLS_CC);
 }
http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/tests/sqlite3_25_create_aggregate.phpt?r1=1.3&r2=1.4&diff_format=u
Index: php-src/ext/sqlite3/tests/sqlite3_25_create_aggregate.phpt
diff -u php-src/ext/sqlite3/tests/sqlite3_25_create_aggregate.phpt:1.3 
php-src/ext/sqlite3/tests/sqlite3_25_create_aggregate.phpt:1.4
--- php-src/ext/sqlite3/tests/sqlite3_25_create_aggregate.phpt:1.3      Wed Aug 
 6 14:02:44 2008
+++ php-src/ext/sqlite3/tests/sqlite3_25_create_aggregate.phpt  Wed Dec 24 
19:21:42 2008
@@ -7,7 +7,7 @@
 
 require_once(dirname(__FILE__) . '/new_db.inc');
 
-function sum_list_step($context, $num_args, $string) {
+function sum_list_step($context, $rows, $string) {
        if (empty($context))
        {
                $context = array('total' => 0, 'values' => array());



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to