Req #73834 [NEW]: PDO PgSQL specify format for COPY FROM
| From: | disassembler at dasm dot cz | Date: | Thu, 29 Dec 2016 16:39:04 +0000 |
| Subject: | Req #73834 [NEW]: PDO PgSQL specify format for COPY FROM | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-206225@lists.php.net to get a copy of this message | ||
From: disassembler at dasm dot cz
Operating system: Any
PHP version: 7.1.0
Package: PDO PgSQL
Bug Type: Feature/Change Request
Bug description:PDO PgSQL specify format for COPY FROM
Description:
------------
PDO::pgsqlCopyFromFile() and PDO::pgsqlCopyFromArray() currently do not
allow to specify format and default to TEXT.
As of PostgreSQL 8.0, allowed formats as per documentation are TEXT, CSV
or BINARY - see
https://www.postgresql.org/docs/current/static/sql-copy.html.
Following
query is not possible to perform using PDO:
COPY temp_csv FROM STDIN DELIMITER ',' CSV;
Only possible workaround includes usage of non-PDO functions as
described in example here -
http://php.net/manual/en/function.pg-end-copy.php
Test script:
---------------
$conn = new PDO("pgsql:dbname=csv_db", "csv_user", "csv_pass");
$conn->pgsqlCopyFromFile("csv_table', "data.csv", ",",
"\\\\N", null/*,
"csv" - parameter does not exist yet*/);
Expected result:
----------------
PDO PgSQL driver executes a query using CSV format.
Actual result:
--------------
PDO PgSQL driver executes a query using default TEXT format, resulting
in error.
PDOException: SQLSTATE[22P04]: Bad copy file format: 7 ERROR: literal
newline found in data HINT: Use "\n" to represent newline.
--
Edit bug report at https://bugs.php.net/bug.php?id=73834&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73834&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73834&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73834&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73834&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73834&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73834&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73834&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73834&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73834&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73834&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73834&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73834&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73834&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73834&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73834&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73834&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73834&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73834&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73834&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73834&r=mysqlcfg