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