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