Re: Back Slash \ issue - Mailing list pgsql-general

From Bruce Momjian
Subject Re: Back Slash \ issue
Date
Msg-id 20190503141001.pow4wl46qaapba6h@momjian.us
Whole thread Raw
In response to Re: Back Slash \ issue  (Bruce Momjian <bruce@momjian.us>)
List pgsql-general
On Fri, May  3, 2019 at 10:04:44AM -0400, Bruce Momjian wrote:
> On thing the original poster might be missing is that the copy DELIMITER
> is used between fields, while backslash is used as an escape before a
> single character.  While it might be tempting to try to redefine the
> escape character with the copy ESCAPE keyword, that keyword only works
> in CSV mode.
> 
> The Postgres COPY format is very reliable and able to dump/reload _any_
> data sequence.  Many commercial data dump implementations are simpler
> but are not able to be as reliable.

For example, if you are using | as a delimiter, how do you represent a
literal | in the data?  You have to use an escape character before it,
and that is what backslash does, and if you have a backslash in your
data, you have to use a backslash before it too.  CSV has a similar
problem with double-quotes in double-quoted strings, and this is handled
by default by using two double-quotes.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +



pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Back Slash \ issue
Next
From: Ravi Krishna
Date:
Subject: Re: Back Slash \ issue