diff options
author | Michael Paquier <michael@paquier.xyz> | 2024-12-18 14:53:42 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2024-12-18 14:53:42 +0900 |
commit | 4b99fed7541e330b669fe488a274c0c69490391c (patch) | |
tree | b341ada15954661dc2fb5eb6015f806d9c480287 /src/interfaces/libpq/fe-connect.c | |
parent | 3f06324705aeb5a4c67b6c08f2016c4c3c756723 (diff) | |
download | postgresql-4b99fed7541e330b669fe488a274c0c69490391c.tar.gz postgresql-4b99fed7541e330b669fe488a274c0c69490391c.zip |
libpq: Add service name to PGconn and PQservice()
This commit adds one field to PGconn for the database service name (if
any), with PQservice() as routine to retrieve it. Like the other
routines of this area, NULL is returned as result if the connection is
NULL.
A follow-up patch will make use of this feature to be able to display
the service name in the psql prompt.
Author: Michael Banck
Reviewed-by: Greg Sabino Mullane
Discusion: https://postgr.es/m/6723c612.050a0220.1567f4.b94a@mx.google.com
Diffstat (limited to 'src/interfaces/libpq/fe-connect.c')
-rw-r--r-- | src/interfaces/libpq/fe-connect.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index aaf87e8e885..ddcc7b60ab0 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -190,7 +190,8 @@ typedef struct _internalPQconninfoOption static const internalPQconninfoOption PQconninfoOptions[] = { {"service", "PGSERVICE", NULL, NULL, - "Database-Service", "", 20, -1}, + "Database-Service", "", 20, + offsetof(struct pg_conn, pgservice)}, {"user", "PGUSER", NULL, NULL, "Database-User", "", 20, @@ -7041,6 +7042,14 @@ PQdb(const PGconn *conn) } char * +PQservice(const PGconn *conn) +{ + if (!conn) + return NULL; + return conn->pgservice; +} + +char * PQuser(const PGconn *conn) { if (!conn) |