Skip to content

Commit b7c9f8a

Browse files
committed
- Fixed bug #61267: pdo_pgsql's PDO::exec() returns the number of SELECTed
rows on postgresql >= 9
1 parent f005f36 commit b7c9f8a

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

NEWS

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2012, PHP 5.3.11
44

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

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

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

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

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ static long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRM
299299
return -1;
300300
}
301301
H->pgoid = PQoidValue(res);
302-
ret = atol(PQcmdTuples(res));
302+
ret = (qs == PGRES_COMMAND_OK) ? atol(PQcmdTuples(res)) : 0L;
303303
PQclear(res);
304304

305305
return ret;

ext/pdo_pgsql/tests/bug61267.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
PDO::exec() returns 0 when the statement is a SELECT.
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
6+
require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
7+
require_once dirname(__FILE__) . '/config.inc';
8+
PDOTest::skip();
9+
?>
10+
--FILE--
11+
<?php
12+
require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
13+
require_once dirname(__FILE__) . '/config.inc';
14+
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
15+
16+
$res = $db->exec('SELECT * from generate_series(1, 42);');
17+
var_dump($res);
18+
echo "Done\n";
19+
?>
20+
--EXPECTF--
21+
int(0)
22+
Done

0 commit comments

Comments
 (0)