"Mattias Kregert" <mattias(at)kregert(dot)se> writes:
> -- ...but this does not.
> % psql -h server mydb -c "set client_encoding to 'latin1'; select * from
> mytable where text='';"
> ERROR: invalid UTF-8 byte sequence detected near byte 0xc5
There is no hope of that ever working, since the string will be read (and
converted to the server's encoding if relevant) before the SET is
executed. Better find another way to do what you want.
regards, tom lane