Re: PQescapeString handling of \0 - Mailing list pgsql-interfaces

From Tom Lane
Subject Re: PQescapeString handling of \0
Date
Msg-id 26244.1065196923@sss.pgh.pa.us
Whole thread Raw
In response to Re: PQescapeString handling of \0  ("Jeroen T. Vermeulen" <jtv@xs4all.nl>)
Responses Re: PQescapeString handling of \0  ("Jeroen T. Vermeulen" <jtv@xs4all.nl>)
List pgsql-interfaces
"Jeroen T. Vermeulen" <jtv@xs4all.nl> writes:
> On Fri, Oct 03, 2003 at 11:31:02AM -0400, Tom Lane wrote:
>> So essentially PQescapeString is going to become like strncpy --- stop
>> at either \0 or the given count.

> I've no idea whether this makes sense, but as a matter of style, shouldn't
> strings containing '\0's be escaped as binary strings anyway?  And if we're
> going to see multibyte encodings growing in popularity (lots of zeroes and
> "high" byte values), perhaps PQescapeString should even be deprecated?

I think you might be confusing PQescapeString (intended for text) with
PQescapeBytea (intended for binary data).  We do not support any text
encodings that require embedded zeroes, and are unlikely to do so
anytime soon.  (Had anyone suggested this as a design goal when we were
doing the recent FE/BE protocol redesign, perhaps the protocol wouldn't
still rely on null-terminated strings.  But no one did and it's too late
now.)
        regards, tom lane


pgsql-interfaces by date:

Previous
From: "Jeroen T. Vermeulen"
Date:
Subject: Re: PQescapeString handling of \0
Next
From: "Jeroen T. Vermeulen"
Date:
Subject: Re: PQescapeString handling of \0