xref: /PHP-8.2/ext/oci8/tests/bug42496_1.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_1_tab",
20    "CREATE table bug42496_1_tab(c1 CLOB, c2 CLOB)",
21    "INSERT INTO bug42496_1_tab VALUES('test1', 'test1')",
22    "INSERT INTO bug42496_1_tab VALUES('test2', 'test2')",
23    "INSERT INTO bug42496_1_tab VALUES('test3', 'test3')"
24);
25
26oci8_test_sql_execute($c, $stmtarray);
27
28// Run Test
29
30echo "Test 1\n";
31
32for ($i = 0; $i < 15000; $i++) {
33    $s = oci_parse($c, "SELECT * from bug42496_1_tab");
34    oci_define_by_name($s, "C1", $col1);
35    oci_define_by_name($s, "C2", $col2);
36    if (oci_execute($s)) {
37        $arr = array();
38        while ($arr = oci_fetch_assoc($s)) {
39            $arr['C1']->free();
40            $arr['C2']->free();
41        }
42    }
43    oci_free_statement($s);
44}
45
46echo "Done\n";
47
48// Cleanup
49
50$stmtarray = array(
51    "DROP table bug42496_1_tab"
52);
53
54oci8_test_sql_execute($c, $stmtarray);
55
56?>
57--EXPECT--
58Test 1
59Done
60