Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 227c180

Browse files
committed
Doc: clarify location of libpq's default service file on Windows.
The documentation didn't specify the name of the per-user service file on Windows, and extrapolating from the pattern used for other config files gave the wrong answer. The fact that it isn't consistent with the others sure seems like a bug, but it's far too late to change that now; we'd just penalize people who worked it out in the past. So, simply document the true state of affairs. In passing, fix some gratuitous differences between the discussions of the service file and the password file. Julien Rouhaud, per question from Dominique Devienne. Backpatch to all supported branches. I (tgl) also chose to back-patch the part of commit ba356a3 that touched libpq.sgml's description of the service file --- in hindsight, I'm not sure why I didn't do so at the time, as it includes some fairly essential information. Discussion: https://postgr.es/m/CAFCRh-_mdLrh8eYVzhRzu4c8bAFEBn=rwoHOmFJcQOTsCy5nig@mail.gmail.com
1 parent 5fd0ccc commit 227c180

File tree

1 file changed

+40
-17
lines changed

1 file changed

+40
-17
lines changed

doc/src/sgml/libpq.sgml

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7103,9 +7103,11 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough)
71037103
<primary><envar>PGSERVICEFILE</envar></primary>
71047104
</indexterm>
71057105
<envar>PGSERVICEFILE</envar> specifies the name of the per-user
7106-
connection service file. If not set, it defaults
7107-
to <filename>~/.pg_service.conf</filename>
7106+
connection service file
71087107
(see <xref linkend="libpq-pgservice"/>).
7108+
Defaults to <filename>~/.pg_service.conf</filename>, or
7109+
<filename>%APPDATA%\postgresql\.pg_service.conf</filename> on
7110+
Microsoft Windows.
71097111
</para>
71107112
</listitem>
71117113

@@ -7385,11 +7387,11 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough)
73857387
The file <filename>.pgpass</filename> in a user's home directory can
73867388
contain passwords to
73877389
be used if the connection requires a password (and no password has been
7388-
specified otherwise). On Microsoft Windows the file is named
7390+
specified otherwise). On Microsoft Windows the file is named
73897391
<filename>%APPDATA%\postgresql\pgpass.conf</filename> (where
73907392
<filename>%APPDATA%</filename> refers to the Application Data subdirectory in
73917393
the user's profile).
7392-
Alternatively, a password file can be specified
7394+
Alternatively, the password file to use can be specified
73937395
using the connection parameter <xref linkend="libpq-connect-passfile"/>
73947396
or the environment variable <envar>PGPASSFILE</envar>.
73957397
</para>
@@ -7448,26 +7450,34 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough)
74487450
<para>
74497451
The connection service file allows libpq connection parameters to be
74507452
associated with a single service name. That service name can then be
7451-
specified by a libpq connection, and the associated settings will be
7453+
specified in a libpq connection string, and the associated settings will be
74527454
used. This allows connection parameters to be modified without requiring
7453-
a recompile of the libpq application. The service name can also be
7455+
a recompile of the libpq-using application. The service name can also be
74547456
specified using the <envar>PGSERVICE</envar> environment variable.
74557457
</para>
74567458

74577459
<para>
7458-
The connection service file can be a per-user service file
7459-
at <filename>~/.pg_service.conf</filename> or the location
7460-
specified by the environment variable <envar>PGSERVICEFILE</envar>,
7461-
or it can be a system-wide file
7462-
at <filename>`pg_config --sysconfdir`/pg_service.conf</filename> or in the directory
7463-
specified by the environment variable
7464-
<envar>PGSYSCONFDIR</envar>. If service definitions with the same
7465-
name exist in the user and the system file, the user file takes
7466-
precedence.
7460+
Service names can be defined in either a per-user service file or a
7461+
system-wide file. If the same service name exists in both the user
7462+
and the system file, the user file takes precedence.
7463+
By default, the per-user service file is named
7464+
<filename>~/.pg_service.conf</filename>.
7465+
On Microsoft Windows, it is named
7466+
<filename>%APPDATA%\postgresql\.pg_service.conf</filename> (where
7467+
<filename>%APPDATA%</filename> refers to the Application Data subdirectory
7468+
in the user's profile). A different file name can be specified by
7469+
setting the environment variable <envar>PGSERVICEFILE</envar>.
7470+
The system-wide file is named <filename>pg_service.conf</filename>.
7471+
By default it is sought in the <filename>etc</filename> directory
7472+
of the <productname>PostgreSQL</productname> installation
7473+
(use <literal>pg_config --sysconfdir</literal> to identify this
7474+
directory precisely). Another directory, but not a different file
7475+
name, can be specified by setting the environment variable
7476+
<envar>PGSYSCONFDIR</envar>.
74677477
</para>
74687478

74697479
<para>
7470-
The file uses an <quote>INI file</quote> format where the section
7480+
Either service file uses an <quote>INI file</quote> format where the section
74717481
name is the service name and the parameters are connection
74727482
parameters; see <xref linkend="libpq-paramkeywords"/> for a list. For
74737483
example:
@@ -7478,9 +7488,22 @@ host=somehost
74787488
port=5433
74797489
user=admin
74807490
</programlisting>
7481-
An example file is provided at
7491+
An example file is provided in
7492+
the <productname>PostgreSQL</productname> installation at
74827493
<filename>share/pg_service.conf.sample</filename>.
74837494
</para>
7495+
7496+
<para>
7497+
Connection parameters obtained from a service file are combined with
7498+
parameters obtained from other sources. A service file setting
7499+
overrides the corresponding environment variable, and in turn can be
7500+
overridden by a value given directly in the connection string.
7501+
For example, using the above service file, a connection string
7502+
<literal>service=mydb port=5434</literal> will use
7503+
host <literal>somehost</literal>, port <literal>5434</literal>,
7504+
user <literal>admin</literal>, and other parameters as set by
7505+
environment variables or built-in defaults.
7506+
</para>
74847507
</sect1>
74857508

74867509

0 commit comments

Comments
 (0)