1--TEST-- 2Bug #49985 (pdo_pgsql prepare() re-use previous aborted transaction) 3--EXTENSIONS-- 4pdo 5pdo_pgsql 6--SKIPIF-- 7<?php 8require __DIR__ . '/config.inc'; 9require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; 10PDOTest::skip(); 11?> 12--FILE-- 13<?php 14require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; 15$db = PDOTest::test_factory(__DIR__ . '/common.phpt'); 16$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 17 18$db->exec("CREATE TABLE b49985 (a int PRIMARY KEY)"); 19 20for ($i = 0; $i < 3; $i++) { 21 try { 22 $db->beginTransaction(); 23 $stmt = $db->prepare("INSERT INTO b49985 (a) VALUES (?)"); 24 var_dump($stmt->execute(array(1))); 25 $db->commit(); 26 } catch (Exception $e) { 27 echo trim(current(explode("\n", $e->getMessage())))."\n"; 28 $db->rollback(); 29 } 30} 31 32?> 33--CLEAN-- 34<?php 35require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; 36$db = PDOTest::test_factory(__DIR__ . '/common.phpt'); 37$db->query('DROP TABLE IF EXISTS b49985 CASCADE'); 38?> 39--EXPECTF-- 40bool(true) 41SQLSTATE[23505]: %sb49985_pkey%s 42SQLSTATE[23505]: %sb49985_pkey%s 43