From 092f3c63efc6a6ce235cfbed45bd05b739de8540 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Sun, 13 Jul 2025 16:52:19 +0900 Subject: libpq: Add "servicefile" connection option This commit adds the possibility to specify a service file in a connection string, using a new option called "servicefile". The parsing of the service file happens so as things are done in this order of priority: - The servicefile connection option. - Environment variable PGSERVICEFILE. - Default path, depending on the HOME environment. Note that in the last default case, we need to fill in "servicefile" for the connection's PQconninfoOption to let clients know which service file has been used for the connection. Some TAP tests are added, with a few tweaks required for Windows when using URIs or connection option values, for the location paths. Author: Torsten Förtsch Co-authored-by: Ryo Kanbayashi Discussion: https://postgr.es/m/CAKkG4_nCjx3a_F3gyXHSPWxD8Sd8URaM89wey7fG_9g7KBkOCQ@mail.gmail.com --- doc/src/sgml/libpq.sgml | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index b2c2cf9eac8..5bf59a19855 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -2320,6 +2320,19 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname + + servicefile + + + This option specifies the name of the per-user connection service file + (see ). + Defaults to ~/.pg_service.conf, or + %APPDATA%\postgresql\.pg_service.conf on + Microsoft Windows. + + + + target_session_attrs @@ -9140,12 +9153,8 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough) PGSERVICEFILE - PGSERVICEFILE specifies the name of the per-user - connection service file - (see ). - Defaults to ~/.pg_service.conf, or - %APPDATA%\postgresql\.pg_service.conf on - Microsoft Windows. + PGSERVICEFILE behaves the same as the + connection parameter. @@ -9576,7 +9585,8 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough) On Microsoft Windows, it is named %APPDATA%\postgresql\.pg_service.conf (where %APPDATA% refers to the Application Data subdirectory - in the user's profile). A different file name can be specified by + in the user's profile). A different file name can be specified using the + servicefile key word in a libpq connection string or by setting the environment variable PGSERVICEFILE. The system-wide file is named pg_service.conf. By default it is sought in the etc directory -- cgit v1.2.3