Re: quoting psql varible as identifier - Mailing list pgsql-hackers

From Tom Lane
Subject Re: quoting psql varible as identifier
Date
Msg-id 9473.1262458402@sss.pgh.pa.us
Whole thread Raw
In response to Re: quoting psql varible as identifier  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: quoting psql varible as identifier
Re: quoting psql varible as identifier
List pgsql-hackers
Pavel Stehule <pavel.stehule@gmail.com> writes:
> here is patch

I looked at this patch a bit, and I think the real problem with it is
that it's not multibyte safe.  You've copied backend code that is
allowed to assume it's in a safe encoding (ie, one where multibyte
characters can't contain non-high-bit-set bytes).  This is not okay
on the client side, see SJIS and similar encodings.

Where you need to start out is by cloning PQescapeStringConn, which does
a similar type of transformation correctly even in unsafe encodings.
I think we'd agreed upthread that libpq should provide
PQescapeIdentifier functionality anyhow.

Once you've actually read that code, you'll realize that it's okay to
treat the error result as a warning, which resolves the other point
of concern.  Just print the message and use the result anyway.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: quoting psql varible as identifier
Next
From: Pavel Stehule
Date:
Subject: Re: quoting psql varible as identifier