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