The following bug has been logged online:
Bug reference: 2114
Logged by: Ben Gould
Email address: ben.gould@free.fr
PostgreSQL version: 8.1.0
Operating system: Mac OS X 10.4.3
Description: (patch) COPY FROM ... end of copy marker corrupt
Details:
With a table like:
CREATE TABLE test_table (
foo text,
bar text,
baz text
);
Using this format for COPY FROM:
COPY test_table FROM STDIN WITH CSV HEADER DELIMITER AS ',' NULL AS 'NULL'
QUOTE AS '\"' ESCAPE AS '\"'
Where the file was generated via:
COPY test_table TO STDOUT WITH CSV HEADER DELIMITER AS ',' NULL AS 'NULL'
QUOTE AS '\"' ESCAPE AS '\"' FORCE QUOTE foo, bar, baz;
I needed this patch:
<<<
--- postgresql-8.1.0.original/src/backend/commands/copy.c 2005-12-13
13:18:16.000000000 +0100
+++ postgresql-8.1.0/src/backend/commands/copy.c 2005-12-13
13:28:28.000000000 +0100
@@ -2531,7 +2531,7 @@
/*
* In CSV mode, we only recognize \. at start of line
*/
- if (c == '\\' && cstate->line_buf.len == 0)
+ if (c == '\\' && !in_quote && cstate->line_buf.len == 0)
{
char c2;
>>>
Because of this error message:
pg_endcopy warning: ERROR: end-of-copy marker corrupt
(We have quoted strings containing things like ..\..\.. in the CSV file
which broke the copy from.)
I was using DBD::Pg as the client library.