Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6b1c4d3

Browse files
committed
psql: Add variable SERVICEFILE
This new psql variable can be used to check which service file has beenused for a connection. Like other variables, this can be set in aPROMPT or reported by an \echo, like these commands:\echo :SERVICEFILE\set PROMPT1 '=(%:SERVICEFILE:)%# 'This relies on commits092f3c6 andfef6da9 to retrieve thisinformation from the connection's PQconninfoOption.Author: Ryo Kanbayashi <kanbayashi.dev@gmail.com>Discussion:https://postgr.es/m/CAKkG4_nCjx3a_F3gyXHSPWxD8Sd8URaM89wey7fG_9g7KBkOCQ@mail.gmail.com
1 parent3c4e26a commit6b1c4d3

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

‎doc/src/sgml/ref/psql-ref.sgml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4623,6 +4623,15 @@ bar
46234623
</listitem>
46244624
</varlistentry>
46254625

4626+
<varlistentry id="app-psql-variables-servicefile">
4627+
<term><varname>SERVICEFILE</varname></term>
4628+
<listitem>
4629+
<para>
4630+
The service file name, if applicable.
4631+
</para>
4632+
</listitem>
4633+
</varlistentry>
4634+
46264635
<varlistentry id="app-psql-variables-shell-error">
46274636
<term><varname>SHELL_ERROR</varname></term>
46284637
<listitem>

‎src/bin/psql/command.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4481,6 +4481,7 @@ SyncVariables(void)
44814481
charvbuf[32];
44824482
constchar*server_version;
44834483
char*service_name;
4484+
char*service_file;
44844485

44854486
/* get stuff from connection */
44864487
pset.encoding=PQclientEncoding(pset.db);
@@ -4500,6 +4501,11 @@ SyncVariables(void)
45004501
if (service_name)
45014502
pg_free(service_name);
45024503

4504+
service_file=get_conninfo_value("servicefile");
4505+
SetVariable(pset.vars,"SERVICEFILE",service_file);
4506+
if (service_file)
4507+
pg_free(service_file);
4508+
45034509
/* this bit should match connection_warnings(): */
45044510
/* Try to get full text form of version, might include "devel" etc */
45054511
server_version=PQparameterStatus(pset.db,"server_version");
@@ -4529,6 +4535,7 @@ UnsyncVariables(void)
45294535
{
45304536
SetVariable(pset.vars,"DBNAME",NULL);
45314537
SetVariable(pset.vars,"SERVICE",NULL);
4538+
SetVariable(pset.vars,"SERVICEFILE",NULL);
45324539
SetVariable(pset.vars,"USER",NULL);
45334540
SetVariable(pset.vars,"HOST",NULL);
45344541
SetVariable(pset.vars,"PORT",NULL);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp