]> granicus.if.org Git - php/commit
Fixed bug #72759 Regression in pgo_pgsql
authorAnatol Belski <ab@php.net>
Sun, 14 Aug 2016 17:33:24 +0000 (19:33 +0200)
committerAnatol Belski <ab@php.net>
Sun, 14 Aug 2016 17:33:24 +0000 (19:33 +0200)
commit977cbc2fff1a3ec9d29a2c0904fae01bfd64c6c2
tree888036771ece2b24d00feef56c3101af8f6fae0e
parent9f1d962ed6057a3996f1b5aa82467a3172e41e8f
Fixed bug #72759 Regression in pgo_pgsql

This is caused by the fix for #72633. Namely, lastval() throws an error,
if no nextval() was called earlier in the same session. This is by all
means correct so far, however inside a transaction it leads to an abort.
This is the opposite to MySQL's last_insert_id() which doesn't produce
any error no matter something were autoincremented or not.

To avoid existing scripts breakage in the stable branches, the previous
patch is extended to revert the transaction to the state before the lastval()
call in case of error. It is done only for 5.6 and 7.0 to retain BC. For 7.1+,
the clean behavior should persist. This is already the current behavior, when
the sequence name is explicitly passed. So there's no reason to obfuscate the
errors where this breakage is valid.
ext/pdo_pgsql/pgsql_driver.c