| From: | Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> |
|---|---|
| To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: PoC - psql - emphases line with table name in verbose output |
| Date: | 2026-04-23 15:17:47 |
| Message-ID: | c978cb1a-c0e6-42f4-9a65-5f19dbf67682@uni-muenster.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andres Freund | 2026-04-23 16:12:37 | oauth integer overflow |
| Previous Message | Bruce Momjian | 2026-04-23 15:10:03 | Re: First draft of PG 19 release notes |