Home > Archive > PostgreSQL Bugs > December 2005 > BUG #2114: (patch) COPY FROM ... end of copy marker corrupt









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author BUG #2114: (patch) COPY FROM ... end of copy marker corrupt
Ben Gould

2005-12-14, 8:26 pm


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;[color=darkred]

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.

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com