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

Commit 4e90052

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 0fc1af1 commit 4e90052

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

doc/src/sgml/libpq.sgml

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

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

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

@@ -978,7 +992,8 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
978992
port component, in a single URI. A URI of the form
979993
<literal>postgresql://host1:port1,host2:port2,host3:port3/</literal>
980994
is equivalent to a connection string of the form
981-
<literal>host=host1,host2,host3 port=port1,port2,port3</literal>. Each
995+
<literal>host=host1,host2,host3 port=port1,port2,port3</literal>.
996+
As further described below, each
982997
host will be tried in turn until a connection is successfully established.
983998
</para>
984999
</sect3>
@@ -989,8 +1004,8 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
9891004
<para>
9901005
It is possible to specify multiple hosts to connect to, so that they are
9911006
tried in the given order. In the Keyword/Value format, the <literal>host</literal>,
992-
<literal>hostaddr</literal>, and <literal>port</literal> options accept a comma-separated
993-
list of values. The same number of elements must be given in each
1007+
<literal>hostaddr</literal>, and <literal>port</literal> options accept comma-separated
1008+
lists of values. The same number of elements must be given in each
9941009
option that is specified, such
9951010
that e.g., the first <literal>hostaddr</literal> corresponds to the first host name,
9961011
the second <literal>hostaddr</literal> corresponds to the second host name, and so
@@ -1000,7 +1015,7 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
10001015

10011016
<para>
10021017
In the connection URI format, you can list multiple <literal>host:port</literal> pairs
1003-
separated by commas, in the <literal>host</literal> component of the URI.
1018+
separated by commas in the <literal>host</literal> component of the URI.
10041019
</para>
10051020

10061021
<para>

0 commit comments

Comments
 (0)