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