pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #7493: Postmaster messages are unreadable in a Windows console
2+ messages / 2 participants
[nested] [flat]

* BUG #7493: Postmaster messages are unreadable in a Windows console
@ 2012-08-14 10:13  exclusion@gmail.com
  0 siblings, 1 reply; 2+ messages in thread

From: exclusion@gmail.com @ 2012-08-14 10:13 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      7493
Logged by:          Alexander LAW
Email address:      exclusion@gmail.com
PostgreSQL version: 9.1.4
Operating system:   Windows
Description:        

When I disable logging collector and try to run postmaster in a command
line, I get no readable text (I see only ASCII symbols).

Please look at the screenshot.
http://oi45.tinypic.com/2ywy5o9.jpg

Best regards,
Alexander





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #7493: Postmaster messages are unreadable in a Windows console
@ 2012-08-14 10:22  Alexander Law <exclusion@gmail.com>
  parent: exclusion@gmail.com
  0 siblings, 0 replies; 2+ messages in thread

From: Alexander Law @ 2012-08-14 10:22 UTC (permalink / raw)
  To: pgsql-bugs

Hello,
while trying to set consistent log encoding (following the discussion 
http://archives.postgresql.org/message-id/5006D340.4000808%40gmail.com), 
I discovered a few bugs, that IMHO should be fixed before.
> When I disable logging collector and try to run postmaster in a command
> line, I get no readable text (I see only ASCII symbols).
>
> Please look at the screenshot.
> http://oi45.tinypic.com/2ywy5o9.jpg

I believe the problem is related to elog.c/write_console. Following 
encoding check can be found there:
if (GetDatabaseEncoding() != GetPlatformEncoding() …
and later, in mbutils.c/pgwin32_toUTF16
codepage = pg_enc2name_tbl[GetDatabaseEncoding()].codepage;

So DatabaseEncoding here is an encoding of the current process messages 
(current encoding). Indeed, when the process connects to a database in 
postinit.c/CheckMyDatabase function it calls 
SetDatabaseEncoding(dbform->encoding); and then

/* Use the right encoding in translated messages */
#ifdef ENABLE_NLS
     pg_bind_textdomain_codeset(textdomain(NULL));
#endif
where the DatabaseEncoding is used again:
int encoding = GetDatabaseEncoding();


So when a database connected, the process messages encoding is the 
database encoding. But until then DatabaseEncoding->encoding == 0 
(PG_SQL_ASCII). However, translated messages are not ASCII-encoded. man 
bind_textdomain_codeset tells:
"By default, the *gettext* family of functions returns translated 
messages in the locale's character encoding, which can be retrieved as 
*nl_langinfo(CODESET)*."
So if DatabaseEncoding can (and should) be used as current process 
messages encoding, then until a database is connected it should be set 
to PlatformEncoding.
I would suggest to add
SetDatabaseEncoding(GetPlatformEncoding());
just before  set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("postgres")); 
in main.c, so it would reflect the same behavior as in  
postinit.c/CheckMyDatabase.
I tested the patch on Windows and it works.

Best regards,
Alexander

Attachments:

main.patch (text/x-patch, 324B) download --- D:\src\main.c 2012-08-13 11:56:48.000000000 +0400 +++ D:\src\postgresql\src\backend\main\main.c 2012-08-14 13:56:19.938905100 +0400 @@ -98,6 +98,8 @@ * error messages to be localized. */ + SetDatabaseEncoding(GetPlatformEncoding()); + set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("postgres")); #ifdef WIN32
^ permalink raw reply [nested|flat] 2+ messages in thread


end of thread, other threads:[~2012-08-14 10:22 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-08-14 10:13 BUG #7493: Postmaster messages are unreadable in a Windows console exclusion@gmail.com
2012-08-14 10:22 ` Alexander Law <exclusion@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox