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