xref: /PHP-8.0/ext/pdo_pgsql/tests/bug67462.phpt (revision f8d79582)
1--TEST--
2PDO PgSQL Bug #67462 (PDO_PGSQL::beginTransaction() wrongly throws exception when not in transaction)
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
6require __DIR__ . '/config.inc';
7require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
8PDOTest::skip();
9?>
10--FILE--
11<?php
12
13require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
14$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt');
15$pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
16
17$pdo->beginTransaction();
18
19try {
20    $pdo->query("CREATE TABLE b67462 (a int NOT NULL PRIMARY KEY DEFERRABLE INITIALLY DEFERRED)");
21    $pdo->query("INSERT INTO b67462 VALUES (1), (1)");
22
23    var_dump($pdo->inTransaction());
24    $pdo->commit(); // This should fail!
25} catch (\Exception $e) {
26    var_dump($pdo->inTransaction());
27    var_dump($pdo->beginTransaction());
28}
29
30?>
31--EXPECT--
32bool(true)
33bool(false)
34bool(true)
35