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