php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51609 pg_copy_to: Invalid results when using fourth parameter
Submitted: 2010-04-20 02:41 UTC Modified: 2010-04-20 16:12 UTC
From: cbandy at jbandy dot com Assigned: felipe (profile)
Status: Closed Package: PostgreSQL related
PHP Version: 5.3.2 OS: Linux
Private report: No CVE-ID: None
 [2010-04-20 02:41 UTC] cbandy at jbandy dot com
Description:
------------
When passing four arguments to pg_copy_to(), the resulting data is corrupted.

My guess is that pg_null_as is being freed improperly. A similar pointer is freed conditionally within pg_copy_from().

Could be related to segfault in bug 35168.

Test script:
---------------
// setup
pg_query($db, 'CREATE TEMP TABLE temp_test_table (a INT)');
pg_query($db, 'INSERT INTO temp_test_table VALUES (1)');

// success
var_dump(pg_copy_to($db, 'temp_test_table'));

// success
var_dump(pg_copy_to($db, 'temp_test_table', "\t"));

// failure
var_dump(pg_copy_to($db, 'temp_test_table', "\t", "\\\\N"));



Expected result:
----------------
Three identical arrays:

array(1) {
  [0]=>
  string(2) "1
"
}
array(1) {
  [0]=>
  string(2) "1
"
}
array(1) {
  [0]=>
  string(2) "1
"
}

Actual result:
--------------
The third array is corrupted:

array(1) {
  [0]=>
  string(2) "1
"
}
array(1) {
  [0]=>
  string(2) "1
"
}
array(1) {
  [0]=>
  string(2) "@�"
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-20 16:11 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=298218
Log: - Fixed bug #51609 (pg_copy_to: Invalid results when using fourth parameter)
 [2010-04-20 16:12 UTC] felipe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
 [2010-04-20 16:12 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC