Peter Eisentraut <peter_e@gmx.net> writes:
> On tor, 2011-11-10 at 19:30 -0500, Tom Lane wrote:
>> I think psql only pays attention to its locale when stdout is a tty.
>> Now *why* it acts like that, I'll leave for Peter to defend.
> We would have to review the original discussion about that. I can see
> arguments for doing it that way and for not doing it that way.
> This, however, still doesn't explain why a ALTER ROLE ... SET
> client_encoding is not taking effect. After all, a plain SET
> client_encoding still works.
The ALTER ROLE *does* take effect ... and then psql overrides it from
the environment. Not sure why you expected differently --- psql doesn't
especially care why the server sent the initial client_encoding that it
did.
BTW, I noticed while experimenting with this that if I have an
environment of LANG="C", psql overrides the client_encoding to be
SQL_ASCII, regardless of what the database encoding is. This seems
like a bad idea, since it removes knowledge rather than adding any.
regards, tom lane