> > > >For bytea, follow this rule: to escape a null character, use
this:
> > > >'\\0'. To escape a backslash, use this: '\\\\'.

Can anybody explain in technical terms why this is implemented 
so inconveniently ?

Since bytea is probably not very common among users yet
we could imho still change it to not do double escapes.

Imho we need to decide where to do the escaping,
eighter in the parser or in the input functions.

I think actually the backend parser has no business changing
constants, he is imho only allowed to parse it, so he knows 
where a constant begins, and where it ends.    

Andreas

Thu, 30 Aug 2001 09:33:15 +0200
"Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at>
RE: Re: Toast,bytea, Text -blob all confusing
Zeugswetter Andreas SB SD wrote:
> 
> > > > >For bytea, follow this rule: to escape a null character, use
> this:
> > > > >'\\0'. To escape a backslash, use this: '\\\\'.
> 
> Can anybody explain in technical terms why this is implemented
> so inconveniently ?

I think that this has to to with making textin and textout behave 
symmetrically, and the requirement that textout must produce a 
valid C-string for ASCII transfer format.

> Since bytea is probably not very common among users yet
> we could imho still change it to not do double escapes.

But how ?

> Imho we need to decide where to do the escaping,
> eighter in the parser or in the input functions.

It would be probably hard to make the parser to _not_ unescape some 
types, as it does not yet know it

> I think actually the backend parser has no business changing
> constants, he is imho only allowed to parse it, so he knows
> where a constant begins, and where it ends.

If it is any consolation then you have to write the inset of 
a single \ from shell command so:

> psql -c "insert into t values('\\\\\\\\')"

;)

------------------
Hannu

Thu, 30 Aug 2001 16:32:18 +0200
Hannu Krosing <hannu@tm.ee>
Re: Re: Toast,bytea, Text -blob all confusing
"Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at> writes:
> I think actually the backend parser has no business changing
> constants, he is imho only allowed to parse it, so he knows 
> where a constant begins, and where it ends.    

How do you propose to handle embedded quote marks in literals,
if there is no parser-level escape convention?

Don't suggest a type-specific escape convention; at the time the
parser runs, it's impossible to know what type the literal will
turn out to be.

			regards, tom lane

Mon, 03 Sep 2001 19:08:11 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: Re: Toast,bytea, Text -blob all confusing 