Re: Escape handling in strings

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Ed L(dot)" <pgsql(at)bluepolka(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Escape handling in strings
Date: 2005-06-21 23:31:38
Message-ID: 200506212331.j5LNVcJ09444@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ed L. wrote:
> On Tuesday June 21 2005 12:49 pm, Bruce Momjian wrote:
> > I have received very few replies to my suggestion that we
> > implement E'' for escaped strings, so eventually, after a few
> > major releases, we can have '' treat backslashes literally
> > like the SQL standard requires.
> >
> > I assume this is because most people say, "yea, it is going to
> > be a pain, and yea, we should probably do it".
>
> I read the webpage, but its still a little muddy. Can you
> clarify/summarize the class of applications, and which dumps
> starting with 7.2*, will fail on clusters with this patch unless
> they are modified?

Well, postgresql.conf controls the warnings, until perhaps 8.3 where a
backslash in a string becomes literal, and \n is treated as \ and n, and
\\ is treated as \ and \, and \' is treated as \ and the end of the
string, and the rest of the string is part of the query, which is really
bad.

So, move \' to '', and when you get to 8.3 you need to use E'' for
escapes.

Dumps from releases before 8.1 might have problems loading in the CREATE
statements, but the COPY format is the same as before.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Neil Conway 2005-06-22 01:45:56 Re: Removing Kerberos 4
Previous Message Roman Neuhauser 2005-06-21 23:30:53 Re: Postfix/Maildrop and too many connections issues