diff options
author | Gustavo André dos Santos Lopes <cataphract@php.net> | 2012-03-08 08:52:28 +0000 |
---|---|---|
committer | Gustavo André dos Santos Lopes <cataphract@php.net> | 2012-03-08 08:52:28 +0000 |
commit | b7c9f8ae8a6c42988a63c778e060e4ce34a3ef91 (patch) | |
tree | 97ca59b76b8a87a3902bc537e1905de23f39a98a /ext/pdo_pgsql | |
parent | f005f36cd6b1dfe50c1f7cb6f4169e69ba5659b8 (diff) | |
download | php-git-b7c9f8ae8a6c42988a63c778e060e4ce34a3ef91.tar.gz |
- Fixed bug #61267: pdo_pgsql's PDO::exec() returns the number of SELECTed
rows on postgresql >= 9
Diffstat (limited to 'ext/pdo_pgsql')
-rw-r--r-- | ext/pdo_pgsql/pgsql_driver.c | 2 | ||||
-rw-r--r-- | ext/pdo_pgsql/tests/bug61267.phpt | 22 |
2 files changed, 23 insertions, 1 deletions
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-- +<?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 |