xref: /PHP-8.3/ext/oci8/tests/bug42496_2.phpt (revision a53e5617)
1--TEST--
2Bug #42496 (LOB fetch leaks cursors, eventually failing with ORA-1000 maximum open cursors reached)
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
8require_once 'skipifconnectfailure.inc';
9$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
10require __DIR__.'/skipif.inc';
11?>
12--FILE--
13<?php
14
15require __DIR__.'/connect.inc';
16
17// Initialization
18
19$stmtarray = array(
20    "DROP table bug42496_2_tab",
21    "CREATE table bug42496_2_tab(c1 CLOB, c2 CLOB)",
22    "INSERT INTO bug42496_2_tab VALUES('test1', 'test1')",
23    "INSERT INTO bug42496_2_tab VALUES('test2', 'test2')",
24    "INSERT INTO bug42496_2_tab VALUES('test3', 'test3')"
25);
26
27oci8_test_sql_execute($c, $stmtarray);
28
29// Run Test
30
31echo "Test 2\n";
32
33for ($i = 0; $i < 15000; $i++) {
34    $s = oci_parse($c, "SELECT * from bug42496_2_tab");
35    if (oci_execute($s)) {
36        $arr = array();
37        while ($arr = oci_fetch_assoc($s)) {
38            $arr['C1']->free();
39            $arr['C2']->free();
40        }
41    }
42    oci_free_statement($s);
43}
44
45echo "Done\n";
46
47// Cleanup
48
49$stmtarray = array(
50    "DROP table bug42496_2_tab"
51);
52
53oci8_test_sql_execute($c, $stmtarray);
54
55?>
56--EXPECT--
57Test 2
58Done
59