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