xref: /PHP-8.4/ext/pgsql/tests/gh10672.phpt (revision c15988aa)
1--TEST--
2GH-10672 (pg_lo_open segfaults in the strict_types mode)
3--EXTENSIONS--
4pgsql
5--SKIPIF--
6<?php
7include("inc/skipif.inc");
8?>
9--FILE--
10<?php
11declare(strict_types=1);
12
13include "inc/config.inc";
14$table_name = 'table_gh10672';
15
16$db = pg_connect($conn_str);
17pg_query($db, "CREATE TABLE {$table_name} (bar text);");
18
19// Begin a transaction
20pg_query($db, 'BEGIN');
21
22// Create an empty large object
23$oid = pg_lo_create($db);
24
25if ($oid === false) {
26    die(pg_last_error($db));
27}
28
29// Open the large object for writing
30$lob = pg_lo_open($db, $oid, 'w');
31
32if ($oid === false) {
33    die(pg_last_error($db));
34}
35
36echo 'The large object has been opened successfully.', PHP_EOL;
37?>
38--CLEAN--
39<?php
40require_once('inc/config.inc');
41$table_name = 'table_gh10672';
42
43$dbh = pg_connect($conn_str);
44pg_query($dbh, "DROP TABLE IF EXISTS {$table_name}");
45?>
46--EXPECT--
47The large object has been opened successfully.
48