1--TEST--
2PECL PDO_OCI Bug #6364 (segmentation fault on stored procedure call with OUT binds)
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded');
6if (getenv('SKIP_ASAN')) die('skip leaks memory under asan');
7require(__DIR__.'/../../pdo/tests/pdo_test.inc');
8PDOTest::skip();
9?>
10--FILE--
11<?php
12
13require __DIR__ . '/../../pdo/tests/pdo_test.inc';
14$dbh = PDOTest::factory();
15
16@$dbh->exec ("drop table bug_6364_t");
17
18$dbh->exec ("create table bug_6364_t (c1 varchar2(10), c2 varchar2(10), c3 varchar2(10), c4 varchar2(10), c5 varchar2(10))");
19
20$dbh->exec ("create or replace procedure bug_6364_sp(p1 IN varchar2, p2 IN varchar2, p3 IN varchar2, p4 OUT varchar2, p5 OUT varchar2) as begin insert into bug_6364_t (c1, c2, c3) values (p1, p2, p3); p4 := 'val4'; p5 := 'val5'; end;");
21
22$stmt = $dbh->prepare("call bug_6364_sp('p1','p2','p3',?,?)");
23
24$out_param1 = "a";
25$out_param2 = "a";
26
27$stmt->bindParam(1, $out_param1,PDO::PARAM_STR, 1024);
28$stmt->bindParam(2, $out_param2,PDO::PARAM_STR, 1024);
29
30$stmt->execute() or die ("Execution error: " . var_dump($dbh->errorInfo()));
31
32var_dump($out_param1);
33var_dump($out_param2);
34
35foreach ($dbh->query("select * from bug_6364_t") as $row) {
36    var_dump($row);
37}
38
39print "Done\n";
40
41// Cleanup
42$dbh->exec ("drop procedure bug_6364_sp");
43$dbh->exec ("drop table bug_6364_t");
44
45?>
46--EXPECT--
47string(4) "val4"
48string(4) "val5"
49array(10) {
50  ["c1"]=>
51  string(2) "p1"
52  [0]=>
53  string(2) "p1"
54  ["c2"]=>
55  string(2) "p2"
56  [1]=>
57  string(2) "p2"
58  ["c3"]=>
59  string(2) "p3"
60  [2]=>
61  string(2) "p3"
62  ["c4"]=>
63  NULL
64  [3]=>
65  NULL
66  ["c5"]=>
67  NULL
68  [4]=>
69  NULL
70}
71Done
72