libpq: Add "servicefile" connection option
authorMichael Paquier <[email protected]>
Sun, 13 Jul 2025 07:52:19 +0000 (16:52 +0900)
committerMichael Paquier <[email protected]>
Sun, 13 Jul 2025 07:52:19 +0000 (16:52 +0900)
commit092f3c63efc6a6ce235cfbed45bd05b739de8540
treece37711db0465c3d5980bcb1184200dda1a59194
parent8893c3ab3661eb397e68a0ace17c680d1e488360
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 <[email protected]>
Co-authored-by: Ryo Kanbayashi <[email protected]>
Discussion: https://postgr.es/m/CAKkG4_nCjx3a_F3gyXHSPWxD8Sd8URaM89wey7fG_9g7KBkOCQ@mail.gmail.com
doc/src/sgml/libpq.sgml
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/libpq-int.h
src/interfaces/libpq/t/006_service.pl