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 thes
8require(__DIR__.'/skipif.inc');
9if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
10if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only");
11if (getenv("USE_ZEND_ALLOC") === "0") {
12    die("skip Zend MM disabled");
13}
14?>
15--INI--
16memory_limit=6M
17--FILE--
18<?php
19
20// This test is dependent on the behavior of the memory manager
21
22require __DIR__.'/connect.inc';
23require __DIR__.'/create_table.inc';
24
25$ora_sql = "INSERT INTO ".$schema.$table_name." (blob)
26                          VALUES (empty_blob())";
27
28$statement = oci_parse($c,$ora_sql);
29oci_execute($statement);
30
31$ora_sql = "SELECT blob 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['BLOB']->write($string);
41}
42
43oci_commit($c);
44
45$ora_sql = "SELECT blob FROM ".$schema.$table_name;
46$statement = oci_parse($c,$ora_sql);
47oci_execute($statement);
48
49echo "Before load()\n";
50
51$row = oci_fetch_assoc($statement);
52var_dump(strlen($row['BLOB']->load())); /* here it should fail */
53
54require __DIR__.'/drop_table.inc';
55
56echo "Done\n";
57?>
58--EXPECTF--
59Before load()
60
61Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d
62