xref: /PHP-8.3/ext/oci8/tests/bug44008.phpt (revision a53e5617)
1--TEST--
2Bug #44008 (Incorrect usage of OCILob->close crashes PHP)
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
9require __DIR__.'/skipif.inc';
10?>
11--FILE--
12<?php
13
14require __DIR__.'/connect.inc';
15
16// Initialization
17
18$stmtarray = array(
19        "create or replace procedure bug44008_proc (p in out clob)
20        as begin p := 'A';
21        end;"
22);
23
24oci8_test_sql_execute($c, $stmtarray);
25
26// Run Test
27
28$s = oci_parse($c, 'begin bug44008_proc(:data); end;');
29$textLob = oci_new_descriptor($c, OCI_D_LOB);
30oci_bind_by_name($s, ":data", $textLob, -1, OCI_B_CLOB);
31oci_execute($s, OCI_DEFAULT);
32$r = $textLob->load();
33echo "$r\n";
34
35// Incorrectly closing the lob doesn't cause a crash.
36// OCI-LOB->close() is documented for use only with OCILob->writeTemporary()
37$textLob->close();
38
39// Cleanup
40
41$stmtarray = array(
42        "drop procedure bug44008_proc"
43);
44
45oci8_test_sql_execute($c, $stmtarray);
46
47echo "Done\n";
48
49?>
50--EXPECT--
51A
52Done
53