Re: Proposal: %T Prompt parameter for psql for current time (like Oracle has) - Mailing list pgsql-hackers

From Kirk Wolak
Subject Re: Proposal: %T Prompt parameter for psql for current time (like Oracle has)
Date
Msg-id CACLU5mQb05z8_BHRfroVQhQGs4kfo8K5rWxq9xMObTgMeGGQ0Q@mail.gmail.com
Whole thread Raw
In response to Re: Proposal: %T Prompt parameter for psql for current time (like Oracle has)  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Proposal: %T Prompt parameter for psql for current time (like Oracle has)
List pgsql-hackers
On Wed, Feb 22, 2023 at 12:55 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Kirk Wolak <wolakk@gmail.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


pgsql-hackers by date:

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