aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/prompt.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2025-07-09 12:46:13 +0900
committerMichael Paquier <michael@paquier.xyz>2025-07-09 12:46:13 +0900
commitfef6da9e9c8790fa915942af2ada190c33fcf98c (patch)
tree455bbc3844dc54548ecb29af282930b66acb31e3 /src/bin/psql/prompt.c
parent93001888d85c21a5b9ab1fe8dabfecb673fc007c (diff)
downloadpostgresql-fef6da9e9c8790fa915942af2ada190c33fcf98c.tar.gz
postgresql-fef6da9e9c8790fa915942af2ada190c33fcf98c.zip
libpq: Remove PQservice()
This routine has been introduced as a shortcut to be able to retrieve a service name from an active connection, for psql. Per discussion, and as it is only used by psql, let's remove it to not clutter the libpq API more than necessary. The logic in psql is replaced by lookups of PQconninfoOption for the active connection, instead, updated each time the variables are synced by psql, the prompt shortcut relying on the variable synced. Reported-by: Noah Misch <noah@leadboat.com> Discussion: https://postgr.es/m/20250706161319.c1.nmisch@google.com Backpatch-through: 18
Diffstat (limited to 'src/bin/psql/prompt.c')
-rw-r--r--src/bin/psql/prompt.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c
index 3aa7d2d06c8..b08d7328fbf 100644
--- a/src/bin/psql/prompt.c
+++ b/src/bin/psql/prompt.c
@@ -169,8 +169,12 @@ get_prompt(promptStatus_t status, ConditionalStack cstack)
break;
/* service name */
case 's':
- if (pset.db && PQservice(pset.db))
- strlcpy(buf, PQservice(pset.db), sizeof(buf));
+ {
+ const char *service_name = GetVariable(pset.vars, "SERVICE");
+
+ if (service_name)
+ strlcpy(buf, service_name, sizeof(buf));
+ }
break;
/* backend pid */
case 'p':