BUG #18439: No way to see national language error messages when running UTF8 scripts with psql.exe on Windows

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: paul(dot)kulakov(at)systematica(dot)ru
Subject: BUG #18439: No way to see national language error messages when running UTF8 scripts with psql.exe on Windows
Date: 2024-04-16 13:13:42
Message-ID: 18439-f2f278cf3ffaac11@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18439
Logged by: Pavel Kulakov
Email address: paul(dot)kulakov(at)systematica(dot)ru
PostgreSQL version: 15.3
Operating system: Windows
Description:

Server has config parameter lc_messages=ru_RU.UTF-8

On Windows with default code page 1251 I run:

chcp 65001
set PGCLIENTENCODING=UTF8
psql --host=localhost --dbname=test --username=test --file=utf8file.sql

The file utf8file.sql is executed OK but if an error occurs psql shows error
message in incorrect encoding.
For example, if utf8file.sql contains string "select 1/0;" I see

psql:utf8file.sql:1: ОШИБКА: деление на ноль
instead of
psql:utf8file.sql:1: ОШИБКА: деление на ноль

======================
Possible solutions:
1) The simplest one is to disable code page translation (CP_ACP ->
ConsoleOutputCP) for stderr (by new psql option?):
_setmode(_fileno(stderr), _O_BINARY);

Of course it will work only if CLIENT_ENCODING corresponds to
ConsoleOutputCP

2) Convert all incoming strings from current CLIENT_ENCODING to active code
page (CP_ACP) before output to console.
======================
Note: at the same time data (tables) output seems all right because of the
magic with pager pipe (indirect output).

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2024-04-16 14:08:15 BUG #18440: Query does not prune partitions correctly or use index when prepared statements are used
Previous Message Noah Misch 2024-04-16 03:58:25 Re: relfrozenxid may disagree with row XIDs after 1ccc1e05ae