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 thes
6require(__DIR__.'/skipif.inc');
7if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
8if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only");
9if (getenv("USE_ZEND_ALLOC") === "0") {
10    die("skip Zend MM disabled");
11}
12?>
13--INI--
14memory_limit=6M
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)
24                          VALUES (empty_blob())";
25
26$statement = oci_parse($c,$ora_sql);
27oci_execute($statement);
28
29$ora_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
30$statement = oci_parse($c,$ora_sql);
31oci_execute($statement, OCI_DEFAULT);
32
33$row = oci_fetch_assoc($statement);
34
35$string = str_repeat("test", 32768*4*4);
36
37for ($i = 0; $i < 8; $i++) {
38    $row['BLOB']->write($string);
39}
40
41oci_commit($c);
42
43$ora_sql = "SELECT blob FROM ".$schema.$table_name;
44$statement = oci_parse($c,$ora_sql);
45oci_execute($statement);
46
47echo "Before load()\n";
48
49$row = oci_fetch_assoc($statement);
50var_dump(strlen($row['BLOB']->load())); /* here it should fail */
51
52require __DIR__.'/drop_table.inc';
53
54echo "Done\n";
55?>
56--EXPECTF--
57Before load()
58
59Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d
60