@@ -303,9 +303,9 @@ PostgresPollingStatusType PQconnectPoll(PGconn *conn);
303
303
<itemizedlist>
304
304
<listitem>
305
305
<para>
306
- The <literal>hostaddr</literal> and <literal>host</literal> parameters are used appropriately to ensure that
307
- name and reverse name queries are not made. See the documentation of
308
- these parameters in <xref linkend="libpq-paramkeywords"/> for details.
306
+ The <literal>hostaddr</literal> parameter must be used appropriately
307
+ to prevent DNS queries from being made. See the documentation of
308
+ this parameter in <xref linkend="libpq-paramkeywords"/> for details.
309
309
</para>
310
310
</listitem>
311
311
@@ -318,32 +318,35 @@ PostgresPollingStatusType PQconnectPoll(PGconn *conn);
318
318
319
319
<listitem>
320
320
<para>
321
- You ensure that the socket is in the appropriate state
321
+ You must ensure that the socket is in the appropriate state
322
322
before calling <function>PQconnectPoll</function>, as described below.
323
323
</para>
324
324
</listitem>
325
325
</itemizedlist>
326
326
</para>
327
327
328
328
<para>
329
- Note: use of <function>PQconnectStartParams</function> is analogous to
330
- <function>PQconnectStart</function> shown below.
329
+ To begin a nonblocking connection request,
330
+ call <function>PQconnectStart</function>
331
+ or <function>PQconnectStartParams</function>. If the result is null,
332
+ then <application>libpq</application> has been unable to allocate a
333
+ new <structname>PGconn</structname> structure. Otherwise, a
334
+ valid <structname>PGconn</structname> pointer is returned (though not
335
+ yet representing a valid connection to the database). Next
336
+ call <literal>PQstatus(conn)</literal>. If the result
337
+ is <symbol>CONNECTION_BAD</symbol>, the connection attempt has already
338
+ failed, typically because of invalid connection parameters.
331
339
</para>
332
340
333
341
<para>
334
- To begin a nonblocking connection request, call <literal>conn = PQconnectStart("<replaceable>connection_info_string</replaceable>")</literal>.
335
- If <varname>conn</varname> is null, then <application>libpq</application> has been unable to allocate a new <structname>PGconn</structname>
336
- structure. Otherwise, a valid <structname>PGconn</structname> pointer is returned (though not yet
337
- representing a valid connection to the database). On return from
338
- <function>PQconnectStart</function>, call <literal>status = PQstatus(conn)</literal>. If <varname>status</varname> equals
339
- <symbol>CONNECTION_BAD</symbol>, <function>PQconnectStart</function> has failed.
340
- </para>
341
-
342
- <para>
343
- If <function>PQconnectStart</function> succeeds, the next stage is to poll
344
- <application>libpq</application> so that it can proceed with the connection sequence.
342
+ If <function>PQconnectStart</function>
343
+ or <function>PQconnectStartParams</function> succeeds, the next stage
344
+ is to poll <application>libpq</application> so that it can proceed with
345
+ the connection sequence.
345
346
Use <function>PQsocket(conn)</function> to obtain the descriptor of the
346
347
socket underlying the database connection.
348
+ (Caution: do not assume that the socket remains the same
349
+ across <function>PQconnectPoll</function> calls.)
347
350
Loop thus: If <function>PQconnectPoll(conn)</function> last returned
348
351
<symbol>PGRES_POLLING_READING</symbol>, wait until the socket is ready to
349
352
read (as indicated by <function>select()</function>, <function>poll()</function>, or
@@ -352,9 +355,8 @@ PostgresPollingStatusType PQconnectPoll(PGconn *conn);
352
355
Conversely, if <function>PQconnectPoll(conn)</function> last returned
353
356
<symbol>PGRES_POLLING_WRITING</symbol>, wait until the socket is ready
354
357
to write, then call <function>PQconnectPoll(conn)</function> again.
355
- If you have yet to call
356
- <function>PQconnectPoll</function>, i.e., just after the call to
357
- <function>PQconnectStart</function>, behave as if it last returned
358
+ On the first iteration, i.e. if you have yet to call
359
+ <function>PQconnectPoll</function>, behave as if it last returned
358
360
<symbol>PGRES_POLLING_WRITING</symbol>. Continue this loop until
359
361
<function>PQconnectPoll(conn)</function> returns
360
362
<symbol>PGRES_POLLING_FAILED</symbol>, indicating the connection procedure
@@ -479,10 +481,12 @@ switch(PQstatus(conn))
479
481
</para>
480
482
481
483
<para>
482
- Note that if <function>PQconnectStart</function> returns a non-null pointer, you must call
483
- <function>PQfinish</function> when you are finished with it, in order to dispose of
484
- the structure and any associated memory blocks. This must be done even if
485
- the connection attempt fails or is abandoned.
484
+ Note that when <function>PQconnectStart</function>
485
+ or <function>PQconnectStartParams</function> returns a non-null
486
+ pointer, you must call <function>PQfinish</function> when you are
487
+ finished with it, in order to dispose of the structure and any
488
+ associated memory blocks. This must be done even if the connection
489
+ attempt fails or is abandoned.
486
490
</para>
487
491
</listitem>
488
492
</varlistentry>
@@ -913,7 +917,8 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
913
917
It is possible to specify multiple hosts to connect to, so that they are
914
918
tried in the given order. In the Keyword/Value format, the <literal>host</literal>,
915
919
<literal>hostaddr</literal>, and <literal>port</literal> options accept a comma-separated
916
- list of values. The same number of elements must be given in each option, such
920
+ list of values. The same number of elements must be given in each
921
+ option that is specified, such
917
922
that e.g. the first <literal>hostaddr</literal> corresponds to the first host name,
918
923
the second <literal>hostaddr</literal> corresponds to the second host name, and so
919
924
forth. As an exception, if only one <literal>port</literal> is specified, it
@@ -922,9 +927,13 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
922
927
923
928
<para>
924
929
In the connection URI format, you can list multiple <literal>host:port</literal> pairs
925
- separated by commas, in the <literal>host</literal> component of the URI. In either
926
- format, a single host name can also translate to multiple network addresses. A
927
- common example of this is a host that has both an IPv4 and an IPv6 address.
930
+ separated by commas, in the <literal>host</literal> component of the URI.
931
+ </para>
932
+
933
+ <para>
934
+ In either format, a single host name can translate to multiple network
935
+ addresses. A common example of this is a host that has both an IPv4 and
936
+ an IPv6 address.
928
937
</para>
929
938
930
939
<para>
@@ -958,9 +967,8 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
958
967
Name of host to connect to.<indexterm><primary>host name</primary></indexterm>
959
968
If a host name begins with a slash, it specifies Unix-domain
960
969
communication rather than TCP/IP communication; the value is the
961
- name of the directory in which the socket file is stored. If
962
- multiple host names are specified, each will be tried in turn in
963
- the order given. The default behavior when <literal>host</literal> is
970
+ name of the directory in which the socket file is stored.
971
+ The default behavior when <literal>host</literal> is
964
972
not specified, or is empty, is to connect to a Unix-domain
965
973
socket<indexterm><primary>Unix domain socket</primary></indexterm> in
966
974
<filename>/tmp</filename> (or whatever socket directory was specified
@@ -997,8 +1005,12 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
997
1005
<itemizedlist>
998
1006
<listitem>
999
1007
<para>
1000
- If <literal>host</literal> is specified without <literal>hostaddr</literal>,
1001
- a host name lookup occurs.
1008
+ If <literal>host</literal> is specified
1009
+ without <literal>hostaddr</literal>, a host name lookup occurs.
1010
+ (When using <function>PQconnectPoll</function>, the lookup occurs
1011
+ when <function>PQconnectPoll</function> first considers this host
1012
+ name, and it may cause <function>PQconnectPoll</function> to block
1013
+ for a significant amount of time.)
1002
1014
</para>
1003
1015
</listitem>
1004
1016
<listitem>
0 commit comments