mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
psql: Add variable SERVICEFILE
This new psql variable can be used to check which service file has been used for a connection. Like other variables, this can be set in a PROMPT or reported by an \echo, like these commands: \echo :SERVICEFILE \set PROMPT1 '=(%:SERVICEFILE:)%# ' This relies on commits092f3c63ef
andfef6da9e9c
to retrieve this information from the connection's PQconninfoOption. Author: Ryo Kanbayashi <kanbayashi.dev@gmail.com> Discussion: https://postgr.es/m/CAKkG4_nCjx3a_F3gyXHSPWxD8Sd8URaM89wey7fG_9g7KBkOCQ@mail.gmail.com
This commit is contained in:
@ -4623,6 +4623,15 @@ bar
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry id="app-psql-variables-servicefile">
|
||||||
|
<term><varname>SERVICEFILE</varname></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The service file name, if applicable.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry id="app-psql-variables-shell-error">
|
<varlistentry id="app-psql-variables-shell-error">
|
||||||
<term><varname>SHELL_ERROR</varname></term>
|
<term><varname>SHELL_ERROR</varname></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@ -4481,6 +4481,7 @@ SyncVariables(void)
|
|||||||
char vbuf[32];
|
char vbuf[32];
|
||||||
const char *server_version;
|
const char *server_version;
|
||||||
char *service_name;
|
char *service_name;
|
||||||
|
char *service_file;
|
||||||
|
|
||||||
/* get stuff from connection */
|
/* get stuff from connection */
|
||||||
pset.encoding = PQclientEncoding(pset.db);
|
pset.encoding = PQclientEncoding(pset.db);
|
||||||
@ -4500,6 +4501,11 @@ SyncVariables(void)
|
|||||||
if (service_name)
|
if (service_name)
|
||||||
pg_free(service_name);
|
pg_free(service_name);
|
||||||
|
|
||||||
|
service_file = get_conninfo_value("servicefile");
|
||||||
|
SetVariable(pset.vars, "SERVICEFILE", service_file);
|
||||||
|
if (service_file)
|
||||||
|
pg_free(service_file);
|
||||||
|
|
||||||
/* this bit should match connection_warnings(): */
|
/* this bit should match connection_warnings(): */
|
||||||
/* Try to get full text form of version, might include "devel" etc */
|
/* Try to get full text form of version, might include "devel" etc */
|
||||||
server_version = PQparameterStatus(pset.db, "server_version");
|
server_version = PQparameterStatus(pset.db, "server_version");
|
||||||
@ -4529,6 +4535,7 @@ UnsyncVariables(void)
|
|||||||
{
|
{
|
||||||
SetVariable(pset.vars, "DBNAME", NULL);
|
SetVariable(pset.vars, "DBNAME", NULL);
|
||||||
SetVariable(pset.vars, "SERVICE", NULL);
|
SetVariable(pset.vars, "SERVICE", NULL);
|
||||||
|
SetVariable(pset.vars, "SERVICEFILE", NULL);
|
||||||
SetVariable(pset.vars, "USER", NULL);
|
SetVariable(pset.vars, "USER", NULL);
|
||||||
SetVariable(pset.vars, "HOST", NULL);
|
SetVariable(pset.vars, "HOST", NULL);
|
||||||
SetVariable(pset.vars, "PORT", NULL);
|
SetVariable(pset.vars, "PORT", NULL);
|
||||||
|
Reference in New Issue
Block a user