xref: /PHP-5.6/ext/pdo_pgsql/tests/bug67462.phpt (revision 9580fcfe)
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 dirname(__FILE__) . '/config.inc';
7require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
8PDOTest::skip();
9?>
10--FILE--
11<?php
12
13require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
14$pdo = PDOTest::test_factory(dirname(__FILE__) . '/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