From: Gustavo André dos Santos Lopes Date: Thu, 8 Mar 2012 08:52:28 +0000 (+0000) Subject: - Fixed bug #61267: pdo_pgsql's PDO::exec() returns the number of SELECTed X-Git-Tag: PHP-5.4.1-RC1~26^2~28 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b7c9f8ae8a6c42988a63c778e060e4ce34a3ef91;p=php - Fixed bug #61267: pdo_pgsql's PDO::exec() returns the number of SELECTed rows on postgresql >= 9 --- diff --git a/NEWS b/NEWS index 2d1bafc51c..e87b7270b6 100644 --- a/NEWS +++ b/NEWS @@ -2,10 +2,6 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 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 @@ PHP NEWS . 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 @@ PHP NEWS . 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) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 8c7ff408a4..1b8e4789d8 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -299,7 +299,7 @@ static long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRM return -1; } H->pgoid = PQoidValue(res); - ret = atol(PQcmdTuples(res)); + ret = (qs == PGRES_COMMAND_OK) ? atol(PQcmdTuples(res)) : 0L; PQclear(res); return ret; diff --git a/ext/pdo_pgsql/tests/bug61267.phpt b/ext/pdo_pgsql/tests/bug61267.phpt new file mode 100644 index 0000000000..4214cd9be0 --- /dev/null +++ b/ext/pdo_pgsql/tests/bug61267.phpt @@ -0,0 +1,22 @@ +--TEST-- +PDO::exec() returns 0 when the statement is a SELECT. +--SKIPIF-- + +--FILE-- +exec('SELECT * from generate_series(1, 42);'); +var_dump($res); +echo "Done\n"; +?> +--EXPECTF-- +int(0) +Done