Lists: | pgsql-hackers |
---|
From: | Michael Banck <mbanck(at)gmx(dot)net> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | [PATCH] Add support for displaying database service in psql prompt |
Date: | 2024-10-31 18:01:54 |
Message-ID: | [email protected] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
I think it might be useful to sometimes display the database service
(i.e. what is defined in ~/.pg_service.conf and used via psql
service=foo) in the psql prompt, e.g. if you have 'test' and 'prod'
services, but both have the same database name. This was also suggested
to me during a recent customer training.
I chose the '%s' tag for it. I had to add the service to PGConn as
PQservice (first patch) to libpq and then use it in psql in the second
patch.
Michael
Attachment | Content-Type | Size |
---|---|---|
v1-0001-Add-PQservice-to-PGConn.patch | text/x-diff | 2.8 KB |
v1-0002-Add-support-for-database-service-to-psql-prompt.patch | text/x-diff | 2.0 KB |
From: | Greg Sabino Mullane <htamfids(at)gmail(dot)com> |
---|---|
To: | Michael Banck <mbanck(at)gmx(dot)net> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [PATCH] Add support for displaying database service in psql prompt |
Date: | 2024-11-20 00:47:58 |
Message-ID: | CAKAnmmKhnHGp4X3FvMAicRsbyiKTWwMJ6oWdkRw2oLVzdeL-0A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Compiled and tested: works fine, so +1 from me. Honestly, I was surprised
%s was still available. :)
Cheers,
Greg
From: | Michael Banck <mbanck(at)gmx(dot)net> |
---|---|
To: | Greg Sabino Mullane <htamfids(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [PATCH] Add support for displaying database service in psql prompt |
Date: | 2024-11-28 20:17:23 |
Message-ID: | [email protected] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
On Tue, Nov 19, 2024 at 07:47:58PM -0500, Greg Sabino Mullane wrote:
> Compiled and tested: works fine, so +1 from me. Honestly, I was surprised
> %s was still available. :)
Thanks. Was that full review? You kept the commitfest item in "Needs
Review" state.
Michael
From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Michael Banck <mbanck(at)gmx(dot)net> |
Cc: | Greg Sabino Mullane <htamfids(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [PATCH] Add support for displaying database service in psql prompt |
Date: | 2024-12-10 07:38:24 |
Message-ID: | [email protected] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, Nov 28, 2024 at 09:17:23PM +0100, Michael Banck wrote:
> Hi,
>
> On Tue, Nov 19, 2024 at 07:47:58PM -0500, Greg Sabino Mullane wrote:
> > Compiled and tested: works fine, so +1 from me. Honestly, I was surprised
> > %s was still available. :)
>
> Thanks. Was that full review? You kept the commitfest item in "Needs
> Review" state.
No objections to this proposal, that can be useful. No objections
with the use of 's' for the shortcut in the psql prompt.
Back to your patch, you are missing two things at quick glance:
- Documentation for the new libpq API in 0001.
- Documentation for the new SERVICE and its new %s (see section called
"Prompting" on the psql page.
So please make sure to provide these with the next version of the
patch.
--
Michael
From: | Michael Banck <mbanck(at)gmx(dot)net> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | Greg Sabino Mullane <htamfids(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [PATCH] Add support for displaying database service in psql prompt |
Date: | 2024-12-16 21:57:49 |
Message-ID: | [email protected] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi Michael,
On Tue, Dec 10, 2024 at 04:38:24PM +0900, Michael Paquier wrote:
> On Thu, Nov 28, 2024 at 09:17:23PM +0100, Michael Banck wrote:
> > On Tue, Nov 19, 2024 at 07:47:58PM -0500, Greg Sabino Mullane wrote:
> > > Compiled and tested: works fine, so +1 from me. Honestly, I was surprised
> > > %s was still available. :)
> >
> > Thanks. Was that full review? You kept the commitfest item in "Needs
> > Review" state.
>
> No objections to this proposal, that can be useful. No objections
> with the use of 's' for the shortcut in the psql prompt.
Cool.
> Back to your patch, you are missing two things at quick glance:
> - Documentation for the new libpq API in 0001.
> - Documentation for the new SERVICE and its new %s (see section called
> "Prompting" on the psql page.
>
> So please make sure to provide these with the next version of the
> patch.
Thanks, I have added the documentation now in v2.
Michael
Attachment | Content-Type | Size |
---|---|---|
v2-0001-Add-PQservice-to-PGConn.patch | text/x-diff | 3.9 KB |
v2-0002-Add-support-for-database-service-to-psql-prompt.patch | text/x-diff | 3.2 KB |
From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Michael Banck <mbanck(at)gmx(dot)net> |
Cc: | Greg Sabino Mullane <htamfids(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [PATCH] Add support for displaying database service in psql prompt |
Date: | 2024-12-17 07:43:21 |
Message-ID: | [email protected] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Mon, Dec 16, 2024 at 10:57:49PM +0100, Michael Banck wrote:
> Thanks, I have added the documentation now in v2.
The doc additions seem fine to me. I've just grabbed three tiny nits,
nothing critical.
+ case 's':
+ if (PQservice(pset.db))
+ strlcpy(buf, PQservice(pset.db), sizeof(buf));
+ break;
Other code paths of get_prompt check for pset.db being NULL. True
that it does not matter when calling PQservice() with a connection
that does not exist. For consistency with the surroundings this
should be done at least?
+ <para>
+ The service from <filename>pg_service.conf</filename>, if applicable.
+ </para>
pg_service.conf is not especially true as it depends on the
environment used. For psql, perhaps just use "The service name, if
applicable". No need to be fancy.
--- a/src/interfaces/libpq/exports.txt
+++ b/src/interfaces/libpq/exports.txt
@@ -205,3 +205,4 @@ PQcancelFinish 202
[...]
+PQservice 206
You didn't miss that, nice.
+ <varlistentry id="app-psql-prompting-s">
+ <term><literal>%s</literal></term>
+ <listitem><para>The name of the service entry, if any.</para></listitem>
+ </varlistentry>
Other entries don't use "if any", would just cut it.
--
Michael
From: | Michael Banck <mbanck(at)gmx(dot)net> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | Greg Sabino Mullane <htamfids(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [PATCH] Add support for displaying database service in psql prompt |
Date: | 2024-12-17 08:42:36 |
Message-ID: | [email protected] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
On Tue, Dec 17, 2024 at 04:43:21PM +0900, Michael Paquier wrote:
> On Mon, Dec 16, 2024 at 10:57:49PM +0100, Michael Banck wrote:
> > Thanks, I have added the documentation now in v2.
>
> The doc additions seem fine to me. I've just grabbed three tiny nits,
> nothing critical.
Thanks for the further review.
> + case 's':
> + if (PQservice(pset.db))
> + strlcpy(buf, PQservice(pset.db), sizeof(buf));
> + break;
>
> Other code paths of get_prompt check for pset.db being NULL. True
> that it does not matter when calling PQservice() with a connection
> that does not exist. For consistency with the surroundings this
> should be done at least?
Ok, I've done that.
>
> + <para>
> + The service from <filename>pg_service.conf</filename>, if applicable.
> + </para>
>
> pg_service.conf is not especially true as it depends on the
> environment used. For psql, perhaps just use "The service name, if
> applicable". No need to be fancy.
Done.
> + <varlistentry id="app-psql-prompting-s">
> + <term><literal>%s</literal></term>
> + <listitem><para>The name of the service entry, if any.</para></listitem>
> + </varlistentry>
>
> Other entries don't use "if any", would just cut it.
Done.
V3 attached.
Michael
Attachment | Content-Type | Size |
---|---|---|
v3-0001-Add-PQservice-to-PGConn.patch | text/x-diff | 3.9 KB |
v3-0002-Add-support-for-database-service-to-psql-prompt.patch | text/x-diff | 3.2 KB |
From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Michael Banck <mbanck(at)gmx(dot)net> |
Cc: | Greg Sabino Mullane <htamfids(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [PATCH] Add support for displaying database service in psql prompt |
Date: | 2024-12-18 06:17:36 |
Message-ID: | [email protected] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Tue, Dec 17, 2024 at 09:42:36AM +0100, Michael Banck wrote:
> Done.
>
> V3 attached.
Done.
--
Michael
From: | Michael Banck <mbanck(at)gmx(dot)net> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | Greg Sabino Mullane <htamfids(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [PATCH] Add support for displaying database service in psql prompt |
Date: | 2024-12-19 12:36:44 |
Message-ID: | [email protected] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
On Wed, Dec 18, 2024 at 03:17:36PM +0900, Michael Paquier wrote:
> On Tue, Dec 17, 2024 at 09:42:36AM +0100, Michael Banck wrote:
> > Done.
> >
> > V3 attached.
>
> Done.
Thanks!
Michael