Re: Better title output for psql \dt \di etc. commands

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Better title output for psql \dt \di etc. commands
Date: 2025-02-03 20:12:57
Message-ID: 446877.1738613577@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Greg Sabino Mullane <htamfids(at)gmail(dot)com> writes:
> I toyed with that for a bit, but as you say, without generating a ton of
> combinations to translate, we'd have to fall back on run-time
> constructions. Neither is ideal. I also realized that I almost never type
> "\dti". Very common for me are \d and \dt and \dv etc. but combinations are
> something I never bother with. At that point, I just do a \d. I think given
> how rare (granted, anecdotally) those combinations are, it's okay if we
> expose people to the "r" word.

Fair. This is already a step forward, so it doesn't have to be
perfect.

Looking at the code, I'm not thrilled with the strspn() coding
method. I'd much rather it relied on the bool flags we already
computed (showTables etc). I'm wondering about adding a step like

int ntypes = (int) showTables + (int) showIndexes + ...

(the explicit coercions to int probably aren't necessary)
and then the code could look like

(ntypes != 1) ? _("List of relations") :
(showTables) ? _("List of tables") :
(showIndexes) ? _("List of indexes") :
...

"ntypes" could also be used to simplify the logic that forces
all the flags on, up at the top of the function.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2025-02-03 20:18:21 Prevent COPY FREEZE on Foreign tables
Previous Message Nathan Bossart 2025-02-03 20:12:47 Re: Commitfest app release on Feb 17 with many improvements