xref: /php-src/ext/pdo_pgsql/tests/bug67462.phpt (revision 6fb81d23)
1--TEST--
2PDO PgSQL Bug #67462 (PDO_PGSQL::beginTransaction() wrongly throws exception when not in 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
13
14require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
15$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt');
16$pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
17
18$pdo->beginTransaction();
19
20try {
21    $pdo->query("CREATE TABLE test67462 (a int NOT NULL PRIMARY KEY DEFERRABLE INITIALLY DEFERRED)");
22    $pdo->query("INSERT INTO test67462 VALUES (1), (1)");
23
24    var_dump($pdo->inTransaction());
25    $pdo->commit(); // This should fail!
26} catch (\Exception $e) {
27    var_dump($pdo->inTransaction());
28    var_dump($pdo->beginTransaction());
29}
30
31?>
32--CLEAN--
33<?php
34require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
35$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt');
36$pdo->query("DROP TABLE IF EXISTS test67462");
37?>
38--EXPECT--
39bool(true)
40bool(false)
41bool(true)
42