BUG #2221: Bad delimiters allowed in COPY ... TO - Mailing list pgsql-bugs

From David Fetter
Subject BUG #2221: Bad delimiters allowed in COPY ... TO
Date
Msg-id 20060129215008.A5965F0B00@svr2.postgresql.org
Whole thread Raw
Responses Re: BUG #2221: Bad delimiters allowed in COPY ... TO
List pgsql-bugs
The following bug has been logged online:

Bug reference:      2221
Logged by:          David Fetter
Email address:      david@fetter.org
PostgreSQL version: all
Operating system:   all
Description:        Bad delimiters allowed in COPY ... TO
Details:

This came up while I was testing my pg_dump "specify DELIMITER AS and/or
NULL AS" patch.

Below is a repro using newline.  A similar problem happens when you specify
the delimiter as a backslash.  Should COPY simply not allow these
delimiters?  What about carriage return?  Just in general, what bytes other
than null ought COPY to reject out of hand?

Also, what regression tests do we want to put in in order to ensure that
COPY ... TO generates output that COPY ... FROM can understand?

CREATE TABLE pqxxevents (
    "year" integer,
    event text
);

COPY pqxxevents ("year", event) FROM stdin DELIMITER AS '^M';
2010^MOdyssey Two
2038^Mtime_t overflow
1971^Mjtv
1981^MC:\\>
1997^MAsian crisis
1999^M\N
1978^Mbloody\t\tcold
1989^MOde an die Freiheit
2001^MNew millennium
2001^M'911' WTC attack
2001^MA Space Odyssey
2002^Mlibpqxx
3001^MFinal Odyssey
\.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #2218: Variables selected in VIEWs under different names break queries using those views
Next
From: David Fetter
Date:
Subject: Re: BUG #2221: Bad delimiters allowed in COPY ... TO