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