bug_49985.phpt 900 B

123456789101112131415161718192021222324252627282930313233343536
  1. --TEST--
  2. Bug #49985 (pdo_pgsql prepare() re-use previous aborted transaction)
  3. --EXTENSIONS--
  4. pdo
  5. pdo_pgsql
  6. --SKIPIF--
  7. <?php
  8. require __DIR__ . '/config.inc';
  9. require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
  10. PDOTest::skip();
  11. ?>
  12. --FILE--
  13. <?php
  14. require __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. $db->exec("CREATE TABLE test (a int PRIMARY KEY)");
  18. for ($i = 0; $i < 3; $i++) {
  19. try {
  20. $db->beginTransaction();
  21. $stmt = $db->prepare("INSERT INTO test (a) VALUES (?)");
  22. var_dump($stmt->execute(array(1)));
  23. $db->commit();
  24. } catch (Exception $e) {
  25. echo trim(current(explode("\n", $e->getMessage())))."\n";
  26. $db->rollback();
  27. }
  28. }
  29. ?>
  30. --EXPECTF--
  31. bool(true)
  32. SQLSTATE[23505]: %stest_pkey%s
  33. SQLSTATE[23505]: %stest_pkey%s