Edit report at https://bugs.php.net/bug.php?id=65199&edit=1

 ID:                 65199
 Updated by:         m...@php.net
 Reported by:        thuejk at gmail dot com
 Summary:            pg_copy_from() modifies input array variable
 Status:             Open
 Type:               Bug
 Package:            PostgreSQL related
 Operating System:   Linux (all?)
 PHP Version:        5.5.0
-Assigned To:        
+Assigned To:        yohgaki
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[2013-07-03 23:04:57] 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"
}



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=65199&edit=1

Reply via email to