Re: Proposal: %T Prompt parameter for psql for current time (like Oracle has)

From: Kirk Wolak <wolakk(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, amborodin86(at)gmail(dot)com, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, samokhvalov(at)gmail(dot)com
Subject: Re: Proposal: %T Prompt parameter for psql for current time (like Oracle has)
Date: 2023-02-22 18:37:31
Message-ID: CACLU5mQb05z8_BHRfroVQhQGs4kfo8K5rWxq9xMObTgMeGGQ0Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Feb 22, 2023 at 12:55 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Kirk Wolak <wolakk(at)gmail(dot)com> writes:
> > Proposal: Simply add the %T (PROMPT variable) to output the current time
> > (HH24:MI:SS) into the prompt.
>
> I'm not really convinced that %`date` isn't a usable solution for this,
> especially since it seems like a very niche requirement. The next
> person who wants it might well have a different desire than you
> for exactly what gets shown. The output of date can be customized,
> but a hard-wired prompt.c feature not so much.
>
> On the whole I'd rather not eat more of the limited namespace for
> psql prompt codes for this.
>
> regards, tom lane
>
Tom,
I totally respect where you are coming from, and you are rightfully the
big dog!

In reverse order. That limited namespace. I assume you mean the 52 alpha
characters, of which, we are using 7,
and this change would make it 8. Can we agree that at the current pace of
consumption it will be decades before
we get to 26, and they appear to be pretty well defended?

I already requested ONLY the HH24 format. 8 characters of output. no
options. It's a waste of time.
After all these years, sqlplus still has only one setting (show it, or
not). I am asking the same here.
And I will gladly defend not changing it! Ever!

I believe that leaves the real question:
Can't we just shell out? (which is what I do no, with issues as stated, and
a lot harder to do from memory if someplace new)

It's far easier in linux than windows to get what you want.
It's much more complicated if you try to use the same pgsqlrc file for
multiple environments and users.

We are talking about adding this much code, and consuming 1 of the
remaining 45 namespace items.
case 'T':
time_t current_time = time(NULL);
struct tm *tm_info = localtime(&current_time);
sprintf(buf, "%02d:%02d:%02d", tm_info->tm_hour,
tm_info->tm_min, tm_info->tm_sec);
break;

Does this help my case at all?
If I crossed any lines, it's not my intention. I was tired of dealing with
this, and helping others to set it up.

With Respect,

Kirk

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirk Wolak 2023-02-22 18:42:22 Re: Proposal: %T Prompt parameter for psql for current time (like Oracle has)
Previous Message Jeff Davis 2023-02-22 18:26:23 allow meson to find ICU in non-standard localtion