Обсуждение: BUG #16108: Colorization to the output of command-line has unproperly behaviors at Windows platform

Поиск
Список
Период
Сортировка

BUG #16108: Colorization to the output of command-line has unproperly behaviors at Windows platform

От
PG Bug reporting form
Дата:
The following bug has been logged on the website:

Bug reference:      16108
Logged by:          Haiying Tang
Email address:      tanghy.fnst@cn.fujitsu.com
PostgreSQL version: 12.0
Operating system:   Windows
Description:

Hello

I found the following release notes in PG12 is not working properly at
Windows.
> •Add colorization to the output of command-line utilities

Following the release note, I've set the the environment variable PG_COLOR
to auto, then I run pg_dump command with an incorrect passwd.
However, the command-line output is not colorized as the release notes
said.

Before  PG_COLOR=auto is set: pg_dump: error: connection to database
"tanghy.fnst" failed: FATAL:
After PG_COLOR=auto is set: pg_dump: error: connection
to database "tanghy.fnst" failed: FATAL

I think the colorization to the output of command-line is not supported at
Windows.
Maybe function "pg_logging_init" at source "src\common\logging.c" should add
a platform check.
Besides, the related release note of PG12 should add some description about
it.

Best Regards,
Tang


On Tue, Nov 12, 2019 at 9:30 PM PG Bug reporting form
<noreply@postgresql.org> wrote:
> The following bug has been logged on the website:
>
> Bug reference:      16108
> Logged by:          Haiying Tang
> Email address:      tanghy.fnst@cn.fujitsu.com
> PostgreSQL version: 12.0
> Operating system:   Windows
> Description:
>
> Hello
>
> I found the following release notes in PG12 is not working properly at
> Windows.
> > •Add colorization to the output of command-line utilities
>
> Following the release note, I've set the the environment variable PG_COLOR
> to auto, then I run pg_dump command with an incorrect passwd.
> However, the command-line output is not colorized as the release notes
> said.
>
> Before  PG_COLOR=auto is set: pg_dump: error: connection to database
> "tanghy.fnst" failed: FATAL:
> After PG_COLOR=auto is set:  [01mpg_dump:  [0m [01;31merror:  [0mconnection
> to database "tanghy.fnst" failed: FATAL
>
> I think the colorization to the output of command-line is not supported at
> Windows.
> Maybe function "pg_logging_init" at source "src\common\logging.c" should add
> a platform check.
> Besides, the related release note of PG12 should add some description about
> it.

Based on this:

https://en.wikipedia.org/wiki/ANSI_escape_code#DOS_and_Windows

... I wonder if it works if you use the new Windows Terminal, and I
wonder if it would work on the older thing if we used the
SetConsoleMode() flag it mentions.



Re: BUG #16108: Colorization to the output of command-line hasunproperly behaviors at Windows platform

От
Juan José Santamaría Flecha
Дата:

On Tue, Nov 12, 2019 at 9:39 AM Thomas Munro <thomas.munro@gmail.com> wrote:

... I wonder if it works if you use the new Windows Terminal, and I
wonder if it would work on the older thing if we used the
SetConsoleMode() flag it mentions.


In order to make it work both things are needed, setting the console mode and a terminal that supports it. Please find attached a patch for so.

Regards,

Juan José Santamaría Flecha
Вложения

RE: BUG #16108: Colorization to the output of command-line has unproperly behaviors at Windows platform

От
"Tang, Haiying"
Дата:

>In order to make it work both things are needed, setting the console mode and a terminal that supports it.

 

Your patch worked fine on windows which supports VT100. But the bug still happened when set PG_COLOR="always" at Windows Terminal that not support VT100. Please see the attached file “Test_result.png” for the NG result. (I used win7 for this test)


To fix the above bug, I made some change to your patch. The new one works fine on my win7(VT100 not support) and win10(VT100 support).

Also, in this new patch(v1), I added some doc change for Windows not support Colorization.  Please find the attached patch for so.

 

Regards,
Tang

 

From: Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>
Sent: Wednesday, November 13, 2019 4:00 AM
To: Thomas Munro <thomas.munro@gmail.com>
Cc: PG Bug reporting form <noreply@postgresql.org>; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>; Tang, Haiying/
海英 <tanghy.fnst@cn.fujitsu.com>
Subject: Re: BUG #16108: Colorization to the output of command-line has unproperly behaviors at Windows platform

 

 

On Tue, Nov 12, 2019 at 9:39 AM Thomas Munro <thomas.munro@gmail.com> wrote:


... I wonder if it works if you use the new Windows Terminal, and I
wonder if it would work on the older thing if we used the
SetConsoleMode() flag it mentions.

 

In order to make it work both things are needed, setting the console mode and a terminal that supports it. Please find attached a patch for so.

 

Regards,

 

Juan José Santamaría Flecha

Вложения

Re: BUG #16108: Colorization to the output of command-line hasunproperly behaviors at Windows platform

От
Juan José Santamaría Flecha
Дата:
Thanks for testing. I am opening a new item in the next commitfest for this topic.

On Fri, Nov 15, 2019 at 5:23 AM Tang, Haiying <tanghy.fnst@cn.fujitsu.com> wrote:

>In order to make it work both things are needed, setting the console mode and a terminal that supports it.

 

Your patch worked fine on windows which supports VT100. But the bug still happened when set PG_COLOR="always" at Windows Terminal that not support VT100. Please see the attached file “Test_result.png” for the NG result. (I used win7 for this test)


To fix the above bug, I made some change to your patch. The new one works fine on my win7(VT100 not support) and win10(VT100 support).


My understanding of the "always" logic is that it has to be enabled no matter what, even if not supported in current output.

Also, in this new patch(v1), I added some doc change for Windows not support Colorization.  Please find the attached patch for so.

 

You cannot change the release notes, if anything it will be added to 12.2 patch notes. It should be added to the 21 (!) utilities that specify the PG_COLOR usage, but I am not so sure that adding a note stating this feature requires Windows 10 >= 1511 update is really a Postgres business.

Please find attached a version that supports older Mingw versions and SDKs.

Regards,

Juan José Santamaría Flecha 



Вложения

Re: BUG #16108: Colorization to the output of command-line hasunproperly behaviors at Windows platform

От
Juan José Santamaría Flecha
Дата:
Thanks for testing. I am opening a new item in the next commitfest for this topic.

On Fri, Nov 15, 2019 at 5:23 AM Tang, Haiying <tanghy.fnst@cn.fujitsu.com> wrote:

>In order to make it work both things are needed, setting the console mode and a terminal that supports it.

 

Your patch worked fine on windows which supports VT100. But the bug still happened when set PG_COLOR="always" at Windows Terminal that not support VT100. Please see the attached file “Test_result.png” for the NG result. (I used win7 for this test)


To fix the above bug, I made some change to your patch. The new one works fine on my win7(VT100 not support) and win10(VT100 support).


My understanding of the "always" logic is that it has to be enabled no matter what, even if not supported in current output.

Also, in this new patch(v1), I added some doc change for Windows not support Colorization.  Please find the attached patch for so.

 

You cannot change the release notes, if anything it will be added to 12.2 patch notes. It should be added to the 21 (!) utilities that specify the PG_COLOR usage, but I am not so sure that adding a note stating this feature requires Windows 10 >= 1511 update is really a Postgres business.

Please find attached a version that supports older Mingw versions and SDKs.

Regards,

Juan José Santamaría Flecha