Skip to content

Commit 5744931

Browse files
committed
Doc: further clarify libpq's description of connection string URIs.
Break the synopsis into named parts to make it less confusing. Make more than zero effort at applying SGML markup. Do a bit of copy-editing of nearby text. The synopsis revision is by Alvaro Herrera and Paul Förster, the rest is my fault. Back-patch to v10 where multi-host connection strings appeared. Discussion: https://postgr.es/m/6E752D6B-487C-463E-B6E2-C32E7FB007EA@gmail.com
1 parent 49076fd commit 5744931

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

doc/src/sgml/libpq.sgml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook_OpenSSL(void);
865865
<para>
866866
Several <application>libpq</application> functions parse a user-specified string to obtain
867867
connection parameters. There are two accepted formats for these strings:
868-
plain <literal>keyword = value</literal> strings
868+
plain keyword/value strings
869869
and URIs. URIs generally follow
870870
<ulink url="https://tools.ietf.org/html/rfc3986">RFC
871871
3986</ulink>, except that multi-host connection strings are allowed
@@ -876,12 +876,14 @@ PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook_OpenSSL(void);
876876
<title>Keyword/Value Connection Strings</title>
877877

878878
<para>
879-
In the first format, each parameter setting is in the form
880-
<literal>keyword = value</literal>. Spaces around the equal sign are
879+
In the keyword/value format, each parameter setting is in the form
880+
<replaceable>keyword</replaceable> <literal>=</literal>
881+
<replaceable>value</replaceable>, with space(s) between settings.
882+
Spaces around a setting's equal sign are
881883
optional. To write an empty value, or a value containing spaces, surround it
882-
with single quotes, e.g., <literal>keyword = 'a value'</literal>. Single
883-
quotes and backslashes within
884-
the value must be escaped with a backslash, i.e., <literal>\'</literal> and
884+
with single quotes, for example <literal>keyword = 'a value'</literal>.
885+
Single quotes and backslashes within
886+
a value must be escaped with a backslash, i.e., <literal>\'</literal> and
885887
<literal>\\</literal>.
886888
</para>
887889

@@ -904,7 +906,19 @@ host=localhost port=5432 dbname=mydb connect_timeout=10
904906
<para>
905907
The general form for a connection <acronym>URI</acronym> is:
906908
<synopsis>
907-
postgresql://[user[:password]@][host][:port][,...][/dbname][?param1=value1&amp;...]
909+
postgresql://<optional><replaceable>userspec</replaceable>@</optional><optional><replaceable>hostspec</replaceable></optional><optional>/<replaceable>dbname</replaceable></optional><optional>?<replaceable>paramspec</replaceable></optional>
910+
911+
<phrase>where <replaceable>userspec</replaceable> is:</phrase>
912+
913+
<replaceable>user</replaceable><optional>:<replaceable>password</replaceable></optional>
914+
915+
<phrase>and <replaceable>hostspec</replaceable> is:</phrase>
916+
917+
<optional><replaceable>host</replaceable></optional><optional>:<replaceable>port</replaceable></optional><optional>,...</optional>
918+
919+
<phrase>and <replaceable>paramspec</replaceable> is:</phrase>
920+
921+
<replaceable>name</replaceable>=<replaceable>value</replaceable><optional>&amp;...</optional>
908922
</synopsis>
909923
</para>
910924

@@ -977,7 +991,8 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
977991
port component, in a single URI. A URI of the form
978992
<literal>postgresql://host1:port1,host2:port2,host3:port3/</literal>
979993
is equivalent to a connection string of the form
980-
<literal>host=host1,host2,host3 port=port1,port2,port3</literal>. Each
994+
<literal>host=host1,host2,host3 port=port1,port2,port3</literal>.
995+
As further described below, each
981996
host will be tried in turn until a connection is successfully established.
982997
</para>
983998
</sect3>
@@ -988,8 +1003,8 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
9881003
<para>
9891004
It is possible to specify multiple hosts to connect to, so that they are
9901005
tried in the given order. In the Keyword/Value format, the <literal>host</literal>,
991-
<literal>hostaddr</literal>, and <literal>port</literal> options accept a comma-separated
992-
list of values. The same number of elements must be given in each
1006+
<literal>hostaddr</literal>, and <literal>port</literal> options accept comma-separated
1007+
lists of values. The same number of elements must be given in each
9931008
option that is specified, such
9941009
that e.g., the first <literal>hostaddr</literal> corresponds to the first host name,
9951010
the second <literal>hostaddr</literal> corresponds to the second host name, and so
@@ -999,7 +1014,7 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
9991014

10001015
<para>
10011016
In the connection URI format, you can list multiple <literal>host:port</literal> pairs
1002-
separated by commas, in the <literal>host</literal> component of the URI.
1017+
separated by commas in the <literal>host</literal> component of the URI.
10031018
</para>
10041019

10051020
<para>

0 commit comments

Comments
 (0)