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

Commit4b99fed

Browse files
committed
libpq: Add service name to PGconn and PQservice()
This commit adds one field to PGconn for the database service name (ifany), with PQservice() as routine to retrieve it. Like the otherroutines of this area, NULL is returned as result if the connection isNULL.A follow-up patch will make use of this feature to be able to displaythe service name in the psql prompt.Author: Michael BanckReviewed-by: Greg Sabino MullaneDiscusion:https://postgr.es/m/6723c612.050a0220.1567f4.b94a@mx.google.com
1 parent3f06324 commit4b99fed

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

‎doc/src/sgml/libpq.sgml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,6 +2530,26 @@ char *PQport(const PGconn *conn);
25302530
</listitem>
25312531
</varlistentry>
25322532

2533+
<varlistentry id="libpq-PQservice">
2534+
<term><function>PQservice</function><indexterm><primary>PQservice</primary></indexterm></term>
2535+
2536+
<listitem>
2537+
<para>
2538+
Returns the service of the active connection.
2539+
2540+
<synopsis>
2541+
char *PQservice(const PGconn *conn);
2542+
</synopsis>
2543+
</para>
2544+
2545+
<para>
2546+
<xref linkend="libpq-PQservice"/> returns <symbol>NULL</symbol> if the
2547+
<parameter>conn</parameter> argument is <symbol>NULL</symbol>.
2548+
Otherwise, if there was no service provided, it returns an empty string.
2549+
</para>
2550+
</listitem>
2551+
</varlistentry>
2552+
25332553
<varlistentry id="libpq-PQtty">
25342554
<term><function>PQtty</function><indexterm><primary>PQtty</primary></indexterm></term>
25352555

‎src/interfaces/libpq/exports.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,4 @@ PQcancelFinish 202
205205
PQsocketPoll 203
206206
PQsetChunkedRowsMode 204
207207
PQgetCurrentTimeUSec 205
208+
PQservice 206

‎src/interfaces/libpq/fe-connect.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ typedef struct _internalPQconninfoOption
190190

191191
staticconstinternalPQconninfoOptionPQconninfoOptions[]= {
192192
{"service","PGSERVICE",NULL,NULL,
193-
"Database-Service","",20,-1},
193+
"Database-Service","",20,
194+
offsetof(structpg_conn,pgservice)},
194195

195196
{"user","PGUSER",NULL,NULL,
196197
"Database-User","",20,
@@ -7040,6 +7041,14 @@ PQdb(const PGconn *conn)
70407041
returnconn->dbName;
70417042
}
70427043

7044+
char*
7045+
PQservice(constPGconn*conn)
7046+
{
7047+
if (!conn)
7048+
returnNULL;
7049+
returnconn->pgservice;
7050+
}
7051+
70437052
char*
70447053
PQuser(constPGconn*conn)
70457054
{

‎src/interfaces/libpq/libpq-fe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ extern intPQrequestCancel(PGconn *conn);
385385

386386
/* Accessor functions for PGconn objects */
387387
externchar*PQdb(constPGconn*conn);
388+
externchar*PQservice(constPGconn*conn);
388389
externchar*PQuser(constPGconn*conn);
389390
externchar*PQpass(constPGconn*conn);
390391
externchar*PQhost(constPGconn*conn);

‎src/interfaces/libpq/libpq-int.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ struct pg_conn
394394
char*fbappname;/* fallback application name */
395395
char*dbName;/* database name */
396396
char*replication;/* connect as the replication standby? */
397+
char*pgservice;/* Postgres service, if any */
397398
char*pguser;/* Postgres username and password, if any */
398399
char*pgpass;
399400
char*pgpassfile;/* path to a file containing password(s) */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp