public inbox for [email protected]  
help / color / mirror / Atom feed
From: Jim Jones <[email protected]>
To: Pavel Stehule <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: Re: PoC - psql - emphases line with table name in verbose output
Date: Thu, 23 Apr 2026 17:17:47 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAFj8pRDarWO-OsR+u0dWs=Y6aVOc+ebb_PJH8CdUuwmdOmR4tA@mail.gmail.com>
References: <CAFj8pRD2MOak45s8=bex3BcncJf2jt9ukx=i9pKmWB1SepZu6g@mail.gmail.com>
	<CAFj8pRDarWO-OsR+u0dWs=Y6aVOc+ebb_PJH8CdUuwmdOmR4tA@mail.gmail.com>

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






view thread (5+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: PoC - psql - emphases line with table name in verbose output
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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