]> granicus.if.org Git - php/commitdiff
Clean up FR #72633
authorMatteo Beccati <mbeccati@php.net>
Thu, 4 Aug 2016 07:28:58 +0000 (09:28 +0200)
committerMatteo Beccati <mbeccati@php.net>
Thu, 4 Aug 2016 07:28:58 +0000 (09:28 +0200)
NEWS
ext/pdo_pgsql/pgsql_driver.c
ext/pdo_pgsql/php_pdo_pgsql_int.h
ext/pdo_pgsql/tests/bug72633.phpt [moved from ext/pdo_pgsql/tests/bug_last_insert_id.phpt with 86% similarity]

diff --git a/NEWS b/NEWS
index 51d59f4026a41784a0c4d130ee6ebe5eabafd2f7..21427cc9e5b05a458d12216ec5ce659aa1b867d3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -72,7 +72,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).
index 52a77684923e0c81e232cdf52c0e23324cb1bc75..5b78bcc438153424784ca39ae2eb47dee58653b1 100644 (file)
@@ -360,12 +360,13 @@ static char *pdo_pgsql_last_insert_id(pdo_dbh_t *dbh, const char *name, unsigned
        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);
index 2876b312b7f806bbfb66f271e780492616d05920..eb645c58c4de5e1d8b69e763da2619345839bbba 100644 (file)
@@ -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;
similarity index 86%
rename from ext/pdo_pgsql/tests/bug_last_insert_id.phpt
rename to ext/pdo_pgsql/tests/bug72633.phpt
index 30dd0f039a0962c1645df698954df3aaef696170..06bd25e6268aa7ba9d9029633e8703064761aef9 100644 (file)
@@ -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');