xref: /PHP-8.1/ext/pgsql/tests/bug65119.phpt (revision 1f427779)
1--TEST--
2Bug #65119 (pg_copy_from() modifies input array variable)
3--EXTENSIONS--
4pgsql
5--SKIPIF--
6<?php
7include("skipif.inc");
8?>
9--FILE--
10<?php
11include 'config.inc';
12
13function test(Array $values, $conn_str) {
14  $connection = pg_pconnect($conn_str, PGSQL_CONNECT_FORCE_NEW);
15  pg_query($connection, "begin");
16  pg_query($connection, "CREATE TABLE bug65119 (i INTEGER)");
17  pg_copy_from($connection, "bug65119", $values, "\t", "NULL");
18  pg_query($connection, "rollback");
19}
20
21$values = Array(1,2,3);
22var_dump($values);
23test($values, $conn_str);
24var_dump($values);
25?>
26--EXPECT--
27array(3) {
28  [0]=>
29  int(1)
30  [1]=>
31  int(2)
32  [2]=>
33  int(3)
34}
35array(3) {
36  [0]=>
37  int(1)
38  [1]=>
39  int(2)
40  [2]=>
41  int(3)
42}
43