xref: /PHP-8.3/ext/pdo_pgsql/tests/gh9411.phpt (revision 218a93b8)
1--TEST--
2Bug GH-9411 (PgSQL large object resource is incorrectly closed)
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
14require __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->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
18
19$db->beginTransaction();
20$oid = $db->pgsqlLOBCreate();
21var_dump($lob = $db->pgsqlLOBOpen($oid, 'wb'));
22fwrite($lob, 'test');
23$db->rollback();
24var_dump($lob);
25
26$db->beginTransaction();
27$oid = $db->pgsqlLOBCreate();
28var_dump($lob = $db->pgsqlLOBOpen($oid, 'wb'));
29fwrite($lob, 'test');
30$db->commit();
31var_dump($lob);
32
33$db->beginTransaction();
34var_dump($lob = $db->pgsqlLOBOpen($oid, 'wb'));
35var_dump(fgets($lob));
36?>
37--EXPECTF--
38resource(%d) of type (stream)
39resource(%d) of type (Unknown)
40resource(%d) of type (stream)
41resource(%d) of type (Unknown)
42resource(%d) of type (stream)
43string(4) "test"
44