Bug #72759 [Csd]: Regression
Edit report at https://bugs.php.net/bug.php?id=72759&edit=1
ID: 72759
Updated by: ab@php.net
Reported by: yunosh@php.net
Summary: Regression
Status: Closed
Type: Bug
Package: PDO PgSQL
PHP Version: master-Git-2016-08-05 (Git)
-Assigned To:
+Assigned To: ab
Block user comment: N
Private report: N
New Comment:
@yunosh, i've applied this patch to retain BC in stable branches. Though, it's unchanged
in 7.1+, please be aware.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2016-08-14 18:07:34] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=977cbc2fff1a3ec9d29a2c0904fae01bfd64c6c2
Log: Fixed bug #72759 Regression in pgo_pgsql
------------------------------------------------------------------------
[2016-08-10 21:55:46] ab@php.net
The following patch has been added/updated:
Patch Name: bug72759.patch
Revision: 1470866146
URL: https://bugs.php.net/patch-display.php?bug=72759&patch=bug72759.patch&revision=1470866146
------------------------------------------------------------------------
[2016-08-10 21:00:23] ab@php.net
Thanks for the further research! Nope, it's not the transaction itself, but the changed
behavior of lastinsertid() method. The call to $pdo->lastInsertId(null); implies a sequence were
used. In this case, the table has no sequence column, so call to the last insert id is the error
that ruins the transaction. It can be seen by viewing $stmt->errorinfo().
The PHP code seems to be not correct in first place, as lastinsertid() method should not be called
without having a sequence. Therefore the bugfix is correct. But since it breaks the existing code,
the question is probably only whether we revert this in the stable branch or some workaround is
possible.
Thanks.
------------------------------------------------------------------------
[2016-08-09 12:59:20] yunosh@php.net
Yes, I was able to trim this down today. It's about transactions. Commenting out the
transaction statements in the following example makes the script work again:
<?php
$pdo = new PDO('pgsql:dbname=test', 'vagrant', '');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$pdo->query('DROP TABLE IF EXISTS "horde_sessionhandler"');
$pdo->query('CREATE TABLE "horde_sessionhandler" ( "session_id"
character varying(32) NOT NULL, "session_lastmodified" integer NOT NULL,
"session_data" bytea, PRIMARY KEY("session_id") )');
$pdo->query('CREATE INDEX "index_horde_sessionhandler_on_session_lastmodified" ON
"horde_sessionhandler" ("session_lastmodified")');
$pdo->beginTransaction();
$pdo->query('INSERT INTO "horde_sessionhandler" ("session_id",
"session_data", "session_lastmodified") VALUES (\'sessionid\',
E\'\\\\x73657373696f6e64617461\', 1470745222)');
var_dump($pdo->lastInsertId(null));
$pdo->commit();
$stmt = $pdo->query('SELECT * FROM "horde_sessionhandler"');
var_dump($stmt);
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
------------------------------------------------------------------------
[2016-08-05 13:40:42] ab@php.net
Thanks for the report. Were you already able to come up with a reproduce code?
Thanks.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=72759
--
Edit this bug report at https://bugs.php.net/bug.php?id=72759&edit=1
Thread (9 messages)