Re: minor changes in psql's \encoding command - Mailing list pgsql-patches

From Tom Lane
Subject Re: minor changes in psql's \encoding command
Date
Msg-id 6800.1041746075@sss.pgh.pa.us
Whole thread Raw
In response to Re: minor changes in psql's \encoding command  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-patches
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Should we throw a warning when the do it?

How?  The backend can't throw such a warning (it has no way to know if
the SET is coming from the client library or a higher level).  The only
way to do it would be for the client library to parse every command
passed through it to look for "SET client_encoding" ... which is
expensive and still not very bulletproof.

Perhaps in the still-mythical 7.4 protocol revision, we could consider
adding a field to backend result messages to show the current client
encoding.  But I misdoubt whether it's worth adding a couple bytes to
*every* backend message to make life safe for clients who both want to
change the encoding on the fly, and want to do so behind the back of the
low-level libraries they're using.  That's a cost paid by everyone to
satisfy a very small group.

I really think that documentation to the effect of "don't do it this
way, do it that other way" is the appropriate solution.

            regards, tom lane

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: minor changes in psql's \encoding command
Next
From: Neil Conway
Date:
Subject: Re: disabled, deferred triggers