Re: PoC - psql - emphases line with table name in verbose output - Mailing list pgsql-hackers

From Jim Jones
Subject Re: PoC - psql - emphases line with table name in verbose output
Date
Msg-id c978cb1a-c0e6-42f4-9a65-5f19dbf67682@uni-muenster.de
Whole thread
In response to Re: PoC - psql - emphases line with table name in verbose output  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
Hi Pavel

On 14/04/2026 05:42, Pavel Stehule wrote:
> rebase, new commit message and minor cleaning
Thanks for the patch!

I tested the patch and setting PG_COLOR highlights the INFO messages.

A few observations:

== string matching is locale-fragile ==

Since the code relies on these fixed strings ...

if (level == PG_LOG_INFO && sgr_info_command &&
  (strncmp(buf, "INFO:  vacuuming", strlen("INFO:  vacuuming")) == 0 ||
   strncmp(buf, "INFO:  repacking", strlen("INFO:  repacking")) == 0 ||
   strncmp(buf, "INFO:  analyzing", strlen("INFO:  analyzing")) == 0))

.. the conditions only work if lc_messages is set to English. For
instance, in German you get a different string, which means that
highlighting won't work:

$ psql postgres -c "VACUUM VERBOSE pg_class;" 2>&1 | grep INFO
INFO:  Vacuum von »postgres.pg_catalog.pg_class«
INFO:  beende Vacuum der Tabelle »postgres.pg_catalog.pg_class«:
Index-Scans: 0

$ psql postgres -c "ANALYSE VERBOSE pg_class;" 2>&1 | grep INFO
INFO:  analysiere »pg_catalog.pg_class«
INFO:  »pg_class«: 15 von 15 Seiten gelesen, enthalten 452 lebende
Zeilen und 0 tote Zeilen; 452 Zeilen in Stichprobe, schätzungsweise 452
Zeilen insgesamt
INFO:  finished analyzing table "postgres.pg_catalog.pg_class"

== fixed command list ==

Future verbose operations, if not added to this list, would silently get
no highlighting.

I'm wondering if it is possible to achieve it (locale-agnostic) only for
certain commands without touching the code on the server side. Only by
checking strings it'll be difficult to identify which INFO messages to
highlight.

Thanks!

Best, Jim




pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: First draft of PG 19 release notes
Next
From: Andres Freund
Date:
Subject: oauth integer overflow