diff options
author | Matteo Beccati <mbeccati@php.net> | 2016-08-04 09:30:48 +0200 |
---|---|---|
committer | Matteo Beccati <mbeccati@php.net> | 2016-08-04 09:30:48 +0200 |
commit | 4003595d6000477e86db9c868375acb577f47131 (patch) | |
tree | 24c80e79b799ff8aa146165aad761a91c84266e0 | |
parent | 2b7a699acd3c064a39c1df8c7f7a0a5b66e07f0c (diff) | |
parent | d3a8e107acb4f729016b6d649bc83a888359fb7d (diff) | |
download | php-git-4003595d6000477e86db9c868375acb577f47131.tar.gz |
Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
Clean up FR #72633
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | ext/pdo_pgsql/pgsql_driver.c | 7 | ||||
-rw-r--r-- | ext/pdo_pgsql/php_pdo_pgsql_int.h | 2 | ||||
-rw-r--r-- | ext/pdo_pgsql/tests/bug72633.phpt (renamed from ext/pdo_pgsql/tests/bug_last_insert_id.phpt) | 2 |
4 files changed, 6 insertions, 7 deletions
@@ -96,7 +96,7 @@ PHP NEWS - PDO_pgsql: . Fixed bug #70313 (PDO statement fails to throw exception). (Matteo) . Implemented FR #72633 (Postgres PDO lastInsertId() should work without - specifying a sequence). (Pablo Santiago Sánchez) + specifying a sequence). (Pablo Santiago Sánchez, Matteo) - Reflection: . Fixed bug #72222 (ReflectionClass::export doesn't handle array constants). diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 6bc1976161..df99912e4c 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -363,12 +363,13 @@ static char *pdo_pgsql_last_insert_id(pdo_dbh_t *dbh, const char *name, size_t * char *id = NULL; PGresult *res; ExecStatusType status; - const char *q[1]; - q[0] = name; - if (PHP_PDO_PGSQL_LASTVAL_PG_VERSION <= PQserverVersion(H->server) && name == NULL) { + if (name == NULL) { res = PQexec(H->server, "SELECT LASTVAL()"); } else { + const char *q[1]; + q[0] = name; + res = PQexecParams(H->server, "SELECT CURRVAL($1)", 1, NULL, q, NULL, NULL, 0); } status = PQresultStatus(res); diff --git a/ext/pdo_pgsql/php_pdo_pgsql_int.h b/ext/pdo_pgsql/php_pdo_pgsql_int.h index 86fc847633..30c2cc2d52 100644 --- a/ext/pdo_pgsql/php_pdo_pgsql_int.h +++ b/ext/pdo_pgsql/php_pdo_pgsql_int.h @@ -29,8 +29,6 @@ #define PHP_PDO_PGSQL_CONNECTION_FAILURE_SQLSTATE "08006" -#define PHP_PDO_PGSQL_LASTVAL_PG_VERSION 80100 - typedef struct { const char *file; int line; diff --git a/ext/pdo_pgsql/tests/bug_last_insert_id.phpt b/ext/pdo_pgsql/tests/bug72633.phpt index 30dd0f039a..06bd25e626 100644 --- a/ext/pdo_pgsql/tests/bug_last_insert_id.phpt +++ b/ext/pdo_pgsql/tests/bug72633.phpt @@ -1,5 +1,5 @@ --TEST-- -currval() vs lastval() - PDO PgSQL Bug #1134 [BUG] New record, PostgreSQL and the Primary key https://github.com/phalcon/cphalcon/issues/1134 +PDO PgSQL Bug #72633 (Postgres PDO lastInsertId() should work without specifying a sequence) --SKIPIF-- <?php if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded'); |