Re: invalidly encoded strings - Mailing list pgsql-hackers

From Tom Lane
Subject Re: invalidly encoded strings
Date
Msg-id 16632.1189396986@sss.pgh.pa.us
Whole thread Raw
In response to Re: invalidly encoded strings  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: invalidly encoded strings
List pgsql-hackers
Jeff Davis <pgsql@j-davis.com> writes:
> If it's done in the scanner it should still accept things like:
>   E'\\377\\000\\377'::bytea
> right? 

Right, that will work, because the transformed literal is '\377\000\377'
(no strange characters there, just what it says) and that has not got
any encoding violations.

> I think the concern is when they use only one slash, like:
>   E'\377\000\377'::bytea
> which, as I mentioned before, is not correct anyway.

Note also that if you have standard_conforming_strings set to ON,
this gives the very same result:
  '\377\000\377'::bytea

I'm not convinced that we need to move heaven and earth to make this
work the same with or without E''.  Basically what I'm thinking is we
should just decree that the de-escaped string literal still has to be
valid per the database encoding.  If you don't want to be bound by that,
use the right number of backslashes to get the thing passed through to
the bytea input routine.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: invalidly encoded strings
Next
From: "Albe Laurenz"
Date:
Subject: Re: invalidly encoded strings