Re: Is it possible to set end-of-data marker for COPY statement. - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Is it possible to set end-of-data marker for COPY statement.
Date
Msg-id 141882.1598983266@sss.pgh.pa.us
Whole thread Raw
In response to Re: Is it possible to set end-of-data marker for COPY statement.  (Bruce Momjian <bruce@momjian.us>)
Responses 回复: Is it possible to set end-of-data marker for COPY statement.  (Junfeng Yang <yjerome@vmware.com>)
List pgsql-hackers
Bruce Momjian <bruce@momjian.us> writes:
> On Tue, Sep  1, 2020 at 06:14:45AM +0000, Junfeng Yang wrote:
>> Data in file "/tmp/data".
>> 
>> 122,as\.d,adad
>> 133,sa dad,adadad

> So, you are using comma as the delimiter, but have \. (backslash-period)
> as a data value.  You need to double-up backslashes in your input data,
> no matter what is after the backslash.  You just happen to hit backslash
> period, but other things like \N could cause problems --- literal
> backslashes have to be doubled.

As mentioned upthread, using CSV format might work better.  In CSV
you aren't necessarily stuck with backslash being treated as an
escape character.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Is it possible to set end-of-data marker for COPY statement.
Next
From: Alvaro Herrera
Date:
Subject: Re: ALTER TABLE .. DETACH PARTITION CONCURRENTLY