felipe          Tue Dec  2 21:02:44 2008 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/pdo_sqlite/tests       pdo_sqlite_createaggregate.phpt 
                                        pdo_sqlite_createfunction.phpt 
                                        pdo_sqlite_lastinsertid.phpt 
                                        pdo_sqlite_transaction.phpt 

  Modified files:              
    /php-src/ext/pdo_sqlite     sqlite_driver.c 
  Log:
  MFH:
  - Fixed memory leaks
  - Added new tests (Coverage++)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_sqlite/sqlite_driver.c?r1=1.20.2.5.2.3&r2=1.20.2.5.2.4&diff_format=u
Index: php-src/ext/pdo_sqlite/sqlite_driver.c
diff -u php-src/ext/pdo_sqlite/sqlite_driver.c:1.20.2.5.2.3 
php-src/ext/pdo_sqlite/sqlite_driver.c:1.20.2.5.2.4
--- php-src/ext/pdo_sqlite/sqlite_driver.c:1.20.2.5.2.3 Mon Dec 31 07:20:10 2007
+++ php-src/ext/pdo_sqlite/sqlite_driver.c      Tue Dec  2 21:02:44 2008
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: sqlite_driver.c,v 1.20.2.5.2.3 2007/12/31 07:20:10 sebastian Exp $ */
+/* $Id: sqlite_driver.c,v 1.20.2.5.2.4 2008/12/02 21:02:44 felipe Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -368,8 +368,8 @@
        }
 
        /* clean up the params */
-       if (argc) {
-               for (i = is_agg; i < argc; i++) {
+       if (zargs) {
+               for (i = is_agg; i < fake_argc; i++) {
                        zval_ptr_dtor(zargs[i]);
                        efree(zargs[i]);
                }
@@ -498,6 +498,7 @@
                MAKE_STD_ZVAL(func->func);
                *(func->func) = *callback;
                zval_copy_ctor(func->func);
+               INIT_PZVAL(func->func);
                
                func->argc = argc;
 
@@ -576,10 +577,12 @@
                MAKE_STD_ZVAL(func->step);
                *(func->step) = *step_callback;
                zval_copy_ctor(func->step);
+               INIT_PZVAL(func->step);
 
                MAKE_STD_ZVAL(func->fini);
                *(func->fini) = *fini_callback;
                zval_copy_ctor(func->fini);
+               INIT_PZVAL(func->fini);
                
                func->argc = argc;
 

http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt?view=markup&rev=1.1
Index: php-src/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt
+++ php-src/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt
--TEST--
PDO_sqlite: Testing sqliteCreateAggregate()
--FILE--
<?php

$db = new pdo('sqlite:memory');

$db->query('CREATE TABLE IF NOT EXISTS foobar (id INT AUTO INCREMENT, name 
TEXT)');

$db->query('INSERT INTO foobar VALUES (NULL, "PHP")');
$db->query('INSERT INTO foobar VALUES (NULL, "PHP6")');

$db->sqliteCreateAggregate('testing', function(&$a, $b) { $a .= $b; return $a; 
}, function(&$v) { return $v; });


foreach ($db->query('SELECT testing(name) FROM foobar') as $row) {
        var_dump($row);
}

$db->query('DROP TABLE foobar');

?>
--EXPECTF--
array(2) {
  ["testing(name)"]=>
  %string|unicode%(2) "12"
  [0]=>
  %string|unicode%(2) "12"
}

http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt?view=markup&rev=1.1
Index: php-src/ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt
+++ php-src/ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt
--TEST--
PDO_sqlite: Testing sqliteCreateFunction()
--FILE--
<?php

$db = new pdo('sqlite:memory');

$db->query('CREATE TABLE IF NOT EXISTS foobar (id INT AUTO INCREMENT, name 
TEXT)');

$db->query('INSERT INTO foobar VALUES (NULL, "PHP")');
$db->query('INSERT INTO foobar VALUES (NULL, "PHP6")');


$db->sqliteCreateFunction('testing', function($v) { return strtolower($v); });


foreach ($db->query('SELECT testing(name) FROM foobar') as $row) {
        var_dump($row);
}

$db->query('DROP TABLE foobar');

?>
--EXPECTF--
array(2) {
  ["testing(name)"]=>
  %string|unicode%(3) "php"
  [0]=>
  %string|unicode%(3) "php"
}
array(2) {
  ["testing(name)"]=>
  %string|unicode%(4) "php6"
  [0]=>
  %string|unicode%(4) "php6"
}

http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_sqlite/tests/pdo_sqlite_lastinsertid.phpt?view=markup&rev=1.1
Index: php-src/ext/pdo_sqlite/tests/pdo_sqlite_lastinsertid.phpt
+++ php-src/ext/pdo_sqlite/tests/pdo_sqlite_lastinsertid.phpt
--TEST--
PDO_sqlite: Testing lastInsertId()
--FILE--
<?php

$db = new pdo('sqlite:memory');
$db->query('CREATE TABLE IF NOT EXISTS foo (id INT AUTO INCREMENT, name TEXT)');
$db->query('INSERT INTO foo VALUES (NULL, "PHP")');
$db->query('INSERT INTO foo VALUES (NULL, "PHP6")');
var_dump($db->query('SELECT * FROM foo'));
var_dump($db->errorInfo());
var_dump($db->lastInsertId());

$db->query('DROP TABLE foo');

?>
--EXPECTF--
object(PDOStatement)#2 (1) {
  ["queryString"]=>
  %string|unicode%(17) "SELECT * FROM foo"
}
array(3) {
  [0]=>
  %string|unicode%(5) "00000"
  [1]=>
  NULL
  [2]=>
  NULL
}
%string|unicode%(1) "2"

http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_sqlite/tests/pdo_sqlite_transaction.phpt?view=markup&rev=1.1
Index: php-src/ext/pdo_sqlite/tests/pdo_sqlite_transaction.phpt
+++ php-src/ext/pdo_sqlite/tests/pdo_sqlite_transaction.phpt
--TEST--
PDO_sqlite: Testing transaction
--FILE--
<?php

$db = new pdo('sqlite:memory');

$db->beginTransaction();

$db->query('CREATE TABLE IF NOT EXISTS foobar (id INT AUTO INCREMENT, name 
TEXT)');
$db->commit();

$db->beginTransaction();
$db->query('INSERT INTO foobar VALUES (NULL, "PHP")');
$db->query('INSERT INTO foobar VALUES (NULL, "PHP6")');
$db->rollback();

$r = $db->query('SELECT COUNT(*) FROM foobar');
var_dump($r->rowCount());


$db->query('DROP TABLE foobar');

?>
--EXPECTF--
int(0)



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

Reply via email to