Re: Feature: psql - display current search_path in prompt - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: Feature: psql - display current search_path in prompt
Date
Msg-id aPuLNucQ-559GSUM@nathan
Whole thread Raw
In response to Re: Feature: psql - display current search_path in prompt  (Florents Tselai <florents.tselai@gmail.com>)
Responses Re: Feature: psql - display current search_path in prompt
List pgsql-hackers
On Fri, Oct 24, 2025 at 05:10:13PM +0300, Florents Tselai wrote:
> Good catch. v2 attached

Thanks.

+     <varlistentry id="app-psql-prompting-S">
+      <term><literal>%S</literal></term>
+      <listitem><para>The current search path.</para></listitem>
+     </varlistentry>

I'd suggest linking to a page about the search_path [0].

+extern const char *session_search_path(void);

This function appears to be unused.

+                    /*
+                     * Distinguish unknown (NULL) from an empty but valid search_path ("").
+                     * If not connected or older server doesn't report it via ParameterStatus,
+                     * show "?".
+                     */
+                    if (!pset.db || PQparameterStatus(pset.db, "search_path") == NULL)
+                        strlcpy(buf, "?", sizeof(buf));
+                    else
+                        strlcpy(buf, PQparameterStatus(pset.db, "search_path"), sizeof(buf));
+                    break;

Shouldn't we move most of this logic to session_search_path() and use it
here?

[0] https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-PATH

-- 
nathan



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Instability of phycodorus in pg_upgrade tests with JIT
Next
From: Andres Freund
Date:
Subject: Re: Improving and extending int128.h to more of numeric.c