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