xref: /PHP-8.3/ext/oci8/tests/bug37581.phpt (revision a53e5617)
1--TEST--
2Bug #37581 (oci_bind_array_by_name clobbers input array when using SQLT_AFC, AVC)
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
9require __DIR__.'/skipif.inc';
10?>
11--FILE--
12<?php
13
14require __DIR__."/connect.inc";
15
16$p1 = "create or replace package BUG37581_PKG as
17type str_array is table of char(2) index by binary_integer;
18procedure array_bind(in_str in str_array, out_str out string);
19end BUG37581_PKG;";
20
21$p2 = "create or replace package body BUG37581_PKG as
22  procedure array_bind(in_str in str_array, out_str out string) is
23  begin
24    for i in 1 .. in_str.count loop
25      out_str := in_str(i);
26    end loop;
27  end array_bind;
28end BUG37581_PKG;";
29
30$s1 = oci_parse($c, $p1);
31$s2 = oci_parse($c, $p2);
32oci_execute($s1);
33oci_execute($s2);
34
35
36$stmt           = oci_parse($c,'begin bug37581_pkg.array_bind(:in_arr, :out_str); end;');
37$strings        = array('A','B','C','D','E');
38
39oci_bind_array_by_name($stmt,':in_arr',$strings,5,1,SQLT_AFC);
40oci_bind_by_name($stmt,':out_str',$result,10);
41
42oci_execute($stmt);
43var_dump($strings);
44
45oci_execute($stmt);
46var_dump($strings);
47
48echo "Done\n";
49?>
50--EXPECT--
51array(5) {
52  [0]=>
53  string(1) "A"
54  [1]=>
55  string(1) "B"
56  [2]=>
57  string(1) "C"
58  [3]=>
59  string(1) "D"
60  [4]=>
61  string(1) "E"
62}
63array(5) {
64  [0]=>
65  string(1) "A"
66  [1]=>
67  string(1) "B"
68  [2]=>
69  string(1) "C"
70  [3]=>
71  string(1) "D"
72  [4]=>
73  string(1) "E"
74}
75Done
76