cataphract                               Thu, 08 Mar 2012 08:52:28 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=324014

Log:
- Fixed bug #61267: pdo_pgsql's PDO::exec() returns the number of SELECTed
  rows on postgresql >= 9

Bug: https://bugs.php.net/61267 (Open) pdo_pgsql's PDO::exec() returns the 
number of SELECTed rows on postgresql >= 9.
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/pdo_pgsql/pgsql_driver.c
    A   php/php-src/branches/PHP_5_3/ext/pdo_pgsql/tests/bug61267.phpt
    U   php/php-src/branches/PHP_5_4/ext/pdo_pgsql/pgsql_driver.c
    A   php/php-src/branches/PHP_5_4/ext/pdo_pgsql/tests/bug61267.phpt
    U   php/php-src/trunk/ext/pdo_pgsql/pgsql_driver.c
    A   php/php-src/trunk/ext/pdo_pgsql/tests/bug61267.phpt

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2012-03-08 08:45:31 UTC (rev 324013)
+++ php/php-src/branches/PHP_5_3/NEWS   2012-03-08 08:52:28 UTC (rev 324014)
@@ -2,10 +2,6 @@
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2012, PHP 5.3.11

-- Array:
-  . Fixed bug #52719 (array_walk_recursive crashes if third param of the
-    function is by reference). (Nikita Popov)
-
 - Core:
   . Fixed bug #61165 (Segfault - strip_tags()). (Laruence)
   . Improved max_input_vars directive to check nested variables (Dmitry).
@@ -25,6 +21,8 @@
   . Fixed bug #60801 (strpbrk() mishandles NUL byte). (Adam)
   . Fixed bug #60227 (header() cannot detect the multi-line header with CR).
     (rui, Gustavo)
+  . Fixed bug #52719 (array_walk_recursive crashes if third param of the
+    function is by reference). (Nikita Popov)
   . Fixed bug #51860 (Include fails with toplevel symlink to /). (Dmitry)

 - Installation
@@ -45,8 +43,13 @@
   . Fixed bug #61194 (PDO should export compression flag with myslqnd).
     (Johannes)

+- PDO_pgsql
+  . Fixed bug #61267 (pdo_pgsql's PDO::exec() returns the number of SELECTed
+    rows on postgresql >= 9). (ben dot pineau at gmail dot com)
+
 - Phar:
-  . Fixed bug #61184 (Phar::webPhar() generates headers with trailing NUL 
bytes). (Nikic)
+  . Fixed bug #61184 (Phar::webPhar() generates headers with trailing NUL
+    bytes). (Nikic)

 - PHP-FPM SAPI:
   . Fixed bug #60811 (php-fpm compilation problem). (rasmus)

Modified: php/php-src/branches/PHP_5_3/ext/pdo_pgsql/pgsql_driver.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo_pgsql/pgsql_driver.c   2012-03-08 
08:45:31 UTC (rev 324013)
+++ php/php-src/branches/PHP_5_3/ext/pdo_pgsql/pgsql_driver.c   2012-03-08 
08:52:28 UTC (rev 324014)
@@ -299,7 +299,7 @@
                return -1;
        }
        H->pgoid = PQoidValue(res);
-       ret = atol(PQcmdTuples(res));
+       ret = (qs == PGRES_COMMAND_OK) ? atol(PQcmdTuples(res)) : 0L;
        PQclear(res);

        return ret;

Added: php/php-src/branches/PHP_5_3/ext/pdo_pgsql/tests/bug61267.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo_pgsql/tests/bug61267.phpt              
                (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/pdo_pgsql/tests/bug61267.phpt      
2012-03-08 08:52:28 UTC (rev 324014)
@@ -0,0 +1,22 @@
+--TEST--
+PDO::exec() returns 0 when the statement is a SELECT.
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not 
loaded');
+require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+require_once dirname(__FILE__) . '/config.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+require_once dirname(__FILE__) . '/config.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+
+$res = $db->exec('SELECT * from generate_series(1, 42);');
+var_dump($res);
+echo "Done\n";
+?>
+--EXPECTF--
+int(0)
+Done


Property changes on: 
php/php-src/branches/PHP_5_3/ext/pdo_pgsql/tests/bug61267.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: php/php-src/branches/PHP_5_4/ext/pdo_pgsql/pgsql_driver.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/pdo_pgsql/pgsql_driver.c   2012-03-08 
08:45:31 UTC (rev 324013)
+++ php/php-src/branches/PHP_5_4/ext/pdo_pgsql/pgsql_driver.c   2012-03-08 
08:52:28 UTC (rev 324014)
@@ -299,7 +299,7 @@
                return -1;
        }
        H->pgoid = PQoidValue(res);
-       ret = atol(PQcmdTuples(res));
+       ret = (qs == PGRES_COMMAND_OK) ? atol(PQcmdTuples(res)) : 0L;
        PQclear(res);

        return ret;

Added: php/php-src/branches/PHP_5_4/ext/pdo_pgsql/tests/bug61267.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/pdo_pgsql/tests/bug61267.phpt              
                (rev 0)
+++ php/php-src/branches/PHP_5_4/ext/pdo_pgsql/tests/bug61267.phpt      
2012-03-08 08:52:28 UTC (rev 324014)
@@ -0,0 +1,22 @@
+--TEST--
+PDO::exec() returns 0 when the statement is a SELECT.
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not 
loaded');
+require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+require_once dirname(__FILE__) . '/config.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+require_once dirname(__FILE__) . '/config.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+
+$res = $db->exec('SELECT * from generate_series(1, 42);');
+var_dump($res);
+echo "Done\n";
+?>
+--EXPECTF--
+int(0)
+Done


Property changes on: 
php/php-src/branches/PHP_5_4/ext/pdo_pgsql/tests/bug61267.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: php/php-src/trunk/ext/pdo_pgsql/pgsql_driver.c
===================================================================
--- php/php-src/trunk/ext/pdo_pgsql/pgsql_driver.c      2012-03-08 08:45:31 UTC 
(rev 324013)
+++ php/php-src/trunk/ext/pdo_pgsql/pgsql_driver.c      2012-03-08 08:52:28 UTC 
(rev 324014)
@@ -299,7 +299,7 @@
                return -1;
        }
        H->pgoid = PQoidValue(res);
-       ret = atol(PQcmdTuples(res));
+       ret = (qs == PGRES_COMMAND_OK) ? atol(PQcmdTuples(res)) : 0L;
        PQclear(res);

        return ret;

Added: php/php-src/trunk/ext/pdo_pgsql/tests/bug61267.phpt
===================================================================
--- php/php-src/trunk/ext/pdo_pgsql/tests/bug61267.phpt                         
(rev 0)
+++ php/php-src/trunk/ext/pdo_pgsql/tests/bug61267.phpt 2012-03-08 08:52:28 UTC 
(rev 324014)
@@ -0,0 +1,22 @@
+--TEST--
+PDO::exec() returns 0 when the statement is a SELECT.
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not 
loaded');
+require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+require_once dirname(__FILE__) . '/config.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+require_once dirname(__FILE__) . '/config.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+
+$res = $db->exec('SELECT * from generate_series(1, 42);');
+var_dump($res);
+echo "Done\n";
+?>
+--EXPECTF--
+int(0)
+Done


Property changes on: php/php-src/trunk/ext/pdo_pgsql/tests/bug61267.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

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

Reply via email to