pg_copy_from() modifies input array variable

Bug #65199 pg_copy_from() modifies input array variable
Submitted: 2013-07-03 23:04 UTC Modified: 2014-10-08 09:00 UTC
From: thuejk at gmail dot com Assigned: yohgaki (profile)
Status: Closed Package: PostgreSQL related
PHP Version: 5.5.0 OS: Linux (all?)
Private report: No CVE-ID: None

 [2013-07-03 23:04 UTC] thuejk at gmail dot com

Description:
------------
The variable holding the array of values I pass to pg_copy_from() is modified by 
pg_copy_from() (ints are changed to strings). Even though there is no pass-by-
reference involved.

This bug also exists in PHP 5.2 at least.

Test script:
---------------
<?php
function test(Array $values) {
  $params = sprintf("host='%s' dbname='%s' user='%s' password='%s'",
                    "localhost",
                    "thue",
                    "thue",
                    "password");
  $connection = pg_pconnect($params, PGSQL_CONNECT_FORCE_NEW);

  pg_query("begin");
  pg_query("CREATE TABLE test(i INTEGER)");
  pg_copy_from($connection, "test", $values, "\t", "NULL");
  pg_query("rollback");
}

$values = Array(1,2,3);
var_dump($values);
test($values);
var_dump($values);
?>


Expected result:
----------------
The two var_dump()s should return identical outputs.

Actual result:
--------------
t@t ~/php/php-5.5.0> ./sapi/cli/php ~/test.php
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}
array(3) {
  [0]=>
  string(1) "1"
  [1]=>
  string(1) "2"
  [2]=>
  string(1) "3"
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports

 [2013-10-02 07:40 UTC] mike@php.net

-Assigned To: +Assigned To: yohgaki

 [2013-10-02 07:40 UTC] mike@php.net

Yasuo, can you have a look, please? Probably just a separation issue.

 [2013-11-28 16:34 UTC] derick@php.net

-Status: Assigned +Status: Closed

 [2013-11-28 16:35 UTC] mike@php.net

-Status: Closed +Status: Assigned

 [2013-11-28 16:35 UTC] mike@php.net

Wrong bug number in commit

 [2013-11-28 16:49 UTC] ab@php.net

-Status: Assigned +Status: Closed

 [2013-11-28 17:42 UTC] mike@php.net

-Status: Closed +Status: Assigned

 [2014-10-07 23:16 UTC] stas@php.net

-Status: Assigned +Status: Closed

 [2014-10-07 23:25 UTC] stas@php.net

-Status: Closed +Status: Re-Opened

 [2014-10-07 23:27 UTC] stas@php.net

-Status: Re-Opened +Status: Closed

 [2014-10-08 09:00 UTC] thuejk at gmail dot com

-Status: Closed +Status: Assigned

 [2014-10-08 09:00 UTC] thuejk at gmail dot com

Still not fixed...