Re: Re: Toast,bytea, Text -blob all confusing - Mailing list pgsql-hackers

From Hannu Krosing
Subject Re: Re: Toast,bytea, Text -blob all confusing
Date
Msg-id 3B8E4E72.1566105A@tm.ee
Whole thread Raw
In response to RE: Re: Toast,bytea, Text -blob all confusing  ("Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at>)
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: Florian Weimer
Date:
Subject: Re: Escaping strings for inclusion into SQL queries
Next
From: Thomas Lockhart
Date:
Subject: Re: INTERVAL type: SQL92 implementation