On Wed, Oct 14, 2026 at 1:45 PM shihao zhong <[email protected]> wrote:
> Yes. glibc honors it too. On Ubuntu 24.04 with glibc 2.39,
> a ja_JP.UTF-8 locale and a UTF8 database, an unpatched psql 19 works,
> and with OUTPUT_CHARSET=EUC-JP it fails:
>
>   ERROR:  invalid byte sequence for encoding "UTF8": 0xc2 0xd0
>
> v4 uses the English label in that case.

Thanks for updating the patch!

With the v4 patch, I encountered another case that causes
an "ERROR: invalid byte sequence" error.

First, I started psql as follows:

    $ OUTPUT_CHARSET=EUC-JP psql -X

When I ran \dn, the output was garbled because of the OUTPUT_CHARSET setting:

    =# \dn
    ???????ް???
       ̾??    |    \xBD?ͭ\xBC
    --------+-------------------
     public | pg_database_owner
    (1 ??)

I then tried unsetting OUTPUT_CHARSET to address garbled output:

    =# \setenv OUTPUT_CHARSET

Running \dn again resulted in an error:

    =# \dn
    ERROR:  invalid byte sequence for encoding "UTF8": 0xc2 0xd0

This seems to happen because psql with the v4 patch sees the current
value of OUTPUT_CHARSET, while NLS continues to use an earlier value
(perhaps the one it saw when psql started??). As a result, seems unsetting
OUTPUT_CHARSET while psql is running can trigger this error.

We should address this case as well, or is it reasonable to ignore it as
an edge case?

Regards,

-- 
Fujii Masao


Reply via email to