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