xref: /PHP-8.3/ext/oci8/tests/pecl_bug10194.phpt (revision a53e5617)
1--TEST--
2PECL Bug #10194 (segfault in Instant Client when memory_limit is reached inside the callback)
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
9require __DIR__.'/skipif.inc';
10if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
11if (getenv("USE_ZEND_ALLOC") === "0") {
12    die("skip Zend MM disabled");
13}
14?>
15--INI--
16memory_limit=10M
17--FILE--
18<?php
19
20require __DIR__.'/connect.inc';
21require __DIR__.'/create_table.inc';
22
23$ora_sql = "INSERT INTO
24                       ".$schema.$table_name." (clob)
25                      VALUES (empty_clob())
26                      ";
27
28$statement = oci_parse($c,$ora_sql);
29oci_execute($statement);
30
31$ora_sql = "SELECT clob FROM ".$schema.$table_name." FOR UPDATE";
32$statement = oci_parse($c,$ora_sql);
33oci_execute($statement, OCI_DEFAULT);
34
35$row = oci_fetch_assoc($statement);
36
37$string = str_repeat("test", 32768*4*4);
38
39for ($i = 0; $i < 8; $i++) {
40    $row['CLOB']->write($string);
41}
42
43oci_commit($c);
44
45$ora_sql = "SELECT clob FROM ".$schema.$table_name."";
46$statement = oci_parse($c,$ora_sql);
47oci_execute($statement);
48
49$row = oci_fetch_assoc($statement);
50var_dump(strlen($row['CLOB']->load())); /* here it should fail */
51
52require __DIR__.'/drop_table.inc';
53
54echo "Done\n";
55?>
56--EXPECTF--
57Fatal error: Allowed memory size of 10485760 bytes exhausted%s(tried to allocate %d bytes) in %s on line %d
58