Skip to content

Commit d3a8e10

Browse files
committed
Clean up FR #72633
1 parent 78488a5 commit d3a8e10

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

NEWS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ PHP NEWS
7272
- PDO_pgsql:
7373
. Fixed bug #70313 (PDO statement fails to throw exception). (Matteo)
7474
. Implemented FR #72633 (Postgres PDO lastInsertId() should work without
75-
specifying a sequence). (Pablo Santiago Sánchez)
75+
specifying a sequence). (Pablo Santiago Sánchez, Matteo)
7676

7777
- Reflection:
7878
. Fixed bug #72222 (ReflectionClass::export doesn't handle array constants).

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,13 @@ static char *pdo_pgsql_last_insert_id(pdo_dbh_t *dbh, const char *name, unsigned
360360
char *id = NULL;
361361
PGresult *res;
362362
ExecStatusType status;
363-
const char *q[1];
364-
q[0] = name;
365363

366-
if (PHP_PDO_PGSQL_LASTVAL_PG_VERSION <= PQserverVersion(H->server) && name == NULL) {
364+
if (name == NULL) {
367365
res = PQexec(H->server, "SELECT LASTVAL()");
368366
} else {
367+
const char *q[1];
368+
q[0] = name;
369+
369370
res = PQexecParams(H->server, "SELECT CURRVAL($1)", 1, NULL, q, NULL, NULL, 0);
370371
}
371372
status = PQresultStatus(res);

ext/pdo_pgsql/php_pdo_pgsql_int.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929

3030
#define PHP_PDO_PGSQL_CONNECTION_FAILURE_SQLSTATE "08006"
3131

32-
#define PHP_PDO_PGSQL_LASTVAL_PG_VERSION 80100
33-
3432
typedef struct {
3533
const char *file;
3634
int line;

ext/pdo_pgsql/tests/bug_last_insert_id.phpt renamed to ext/pdo_pgsql/tests/bug72633.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
currval() vs lastval() - PDO PgSQL Bug #1134 [BUG] New record, PostgreSQL and the Primary key https://github.com/phalcon/cphalcon/issues/1134
2+
PDO PgSQL Bug #72633 (Postgres PDO lastInsertId() should work without specifying a sequence)
33
--SKIPIF--
44
<?php
55
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');

0 commit comments

Comments
 (0)