From: | Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> |
---|---|
To: | Florents Tselai <florents(dot)tselai(at)gmail(dot)com>, Jelte Fennema-Nio <postgres(at)jeltef(dot)nl> |
Cc: | Lauri Siltanen <lauri(dot)siltanen(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Feature: psql - display current search_path in prompt |
Date: | 2025-06-10 12:51:16 |
Message-ID: | e968c298-81a0-4276-9f9c-a89ba4507960@uni-muenster.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Florents
On 10.06.25 13:36, Florents Tselai wrote:
>
> On Tue, Jun 10, 2025 at 2:08 AM Jelte Fennema-Nio <postgres(at)jeltef(dot)nl
> <mailto:postgres(at)jeltef(dot)nl>> wrote:
>
> On Mon, 9 Jun 2025 at 17:54, Florents Tselai
> <florents(dot)tselai(at)gmail(dot)com <mailto:florents(dot)tselai(at)gmail(dot)com>> wrote:
> > Here’s a quick attempt that makes %S substitue for a search_path
> > Like
> > \set PROMPT1 'user:%n search_path: %S'
>
> + else
> + return PQuser(pset.db);
>
> That seems like a copy paste error. If we don't have data for it, we
> should either use the empty string, or some string like "<unknown>".
>
>
> Opted for an empty string
>
>
> Other than that, the patch looks good (but I haven't tested it yet).
>
I've taken a quick look at the patch, and it seems to work as expected.
== PROMPT1 ==
postgres=# \set PROMPT1 '(search_path: %S) ;; '
(search_path: "$user", public) ;; SET search_path TO s1, public;
SET
(search_path: s1, public) ;; SET search_path TO s2, public;
SET
(search_path: s2, public) ;; RESET search_path;
RESET
(search_path: "$user", public) ;;
== PROMPT2 ==
postgres=# \set PROMPT2 '(search_path: %S) ** '
postgres=# SELECT
(search_path: "$user", public) ** ^C
postgres=# SET search_path TO s1, public;
SET
postgres=# SELECT
(search_path: s1, public) ** ^C
postgres=# SET search_path TO s2, public;
SET
postgres=# SELECT
(search_path: s2, public) ** ^C
postgres=# RESET search_path;
RESET
postgres=# SELECT
(search_path: "$user", public) **
== PROMPT3 ==
postgres=# \set PROMPT3 '(search_path: %S) ## '
postgres=# COPY t1 (a) FROM STDIN;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself, or an EOF signal.
(search_path: "$user", public) ## 1
(search_path: "$user", public) ## 2
(search_path: "$user", public) ## \.
COPY 2
postgres=# SET search_path TO s1, public;
SET
postgres=# COPY t1 (a) FROM STDIN;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself, or an EOF signal.
(search_path: s1, public) ## 42
(search_path: s1, public) ## 73
(search_path: s1, public) ## \.
COPY 2
postgres=# RESET search_path;
RESET
postgres=# COPY t1 (a) FROM STDIN;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself, or an EOF signal.
(search_path: "$user", public) ## 0
(search_path: "$user", public) ## 1
(search_path: "$user", public) ## \.
COPY 2
Documentation looks ok as well -- it aligns with the other entries in
the file.
>
> Btw - I haven't worked on bin/psql code;
> aren't these auto tested?
I also couldn't find any test related to psql's PROMPT*. Perhaps Jelte
knows more about it?
Best regards,
Jim
From | Date | Subject | |
---|---|---|---|
Next Message | David Geier | 2025-06-10 12:59:10 | Buffer overflow in SerializeLibraryState() found by Address Sanitizer |
Previous Message | Ashutosh Bapat | 2025-06-10 11:51:35 | Re: pg_dump/pg_dumpall help synopses and terminology |