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

Commit cb8b41c

Browse files
author
Liudmila Mantrova
committed
[Doc]: Switch to PGPRO10: autocommit based on d0c1682 (doc/ only)
1 parent 011c692 commit cb8b41c

File tree

1 file changed

+49
-14
lines changed

1 file changed

+49
-14
lines changed

doc/src/sgml/libpq.sgml

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ PostgresPollingStatusType PQconnectPoll(PGconn *conn);
330330
socket underlying the database connection.
331331
Loop thus: If <function>PQconnectPoll(conn)</function> last returned
332332
<symbol>PGRES_POLLING_READING</symbol>, wait until the socket is ready to
333-
read (as indicated by <function>select()</>, <function>poll()</>, or
334-
similar system function).
333+
read (as indicated by <function>PQselect()</> or
334+
<function>PQselectExtended()</>).
335335
Then call <function>PQconnectPoll(conn)</function> again.
336336
Conversely, if <function>PQconnectPoll(conn)</function> last returned
337337
<symbol>PGRES_POLLING_WRITING</symbol>, wait until the socket is ready
@@ -1943,6 +1943,42 @@ int PQsocket(const PGconn *conn);
19431943
</listitem>
19441944
</varlistentry>
19451945

1946+
<varlistentry id="libpq-pqselect">
1947+
<term><function>PQselect</function><indexterm><primary>PQselect</></></term>
1948+
<listitem>
1949+
<para>
1950+
Uses select(2) to monitor multiple file descriptors, waiting until one or
1951+
more of the file descriptors become "ready" for some class of I/O
1952+
operation (e.g., input possible).
1953+
1954+
<synopsis>
1955+
int PQselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout, int isRsocket);
1956+
</synopsis>
1957+
1958+
</para>
1959+
</listitem>
1960+
</varlistentry>
1961+
1962+
<varlistentry id="libpq-pqselectextended">
1963+
<term><function>PQselectExtended</function><indexterm><primary>PQselectExtended</></></term>
1964+
<listitem>
1965+
<para>
1966+
Uses select(2) or poll(2) to wait for input. The <literal>timeout</>
1967+
argument specifies the number of milliseconds that
1968+
<function>PQselectExtended</> should block waiting for a file descriptor
1969+
of the connection to become ready. Specifying a negative value
1970+
in <literal>timeout</> means an infinite timeout. Specifying a
1971+
<literal>timeout</> of zero causes <function>poll()</> to return
1972+
immediately.
1973+
1974+
<synopsis>
1975+
int PQselectExtended(const PGconn *conn, int timeout_ms);
1976+
</synopsis>
1977+
1978+
</para>
1979+
</listitem>
1980+
</varlistentry>
1981+
19461982
<varlistentry id="libpq-pqbackendpid">
19471983
<term><function>PQbackendPID</function><indexterm><primary>PQbackendPID</></></term>
19481984
<listitem>
@@ -4558,10 +4594,10 @@ int PQconsumeInput(PGconn *conn);
45584594
<function>PQconsumeInput</function> can be called even if the
45594595
application is not prepared to deal with a result or notification
45604596
just yet. The function will read available data and save it in
4561-
a buffer, thereby causing a <function>select()</function>
4597+
a buffer, thereby causing a <function>PQselect()</function>
45624598
read-ready indication to go away. The application can thus use
45634599
<function>PQconsumeInput</function> to clear the
4564-
<function>select()</function> condition immediately, and then
4600+
<function>PQselect()</function> condition immediately, and then
45654601
examine the results at leisure.
45664602
</para>
45674603
</listitem>
@@ -4598,10 +4634,10 @@ int PQisBusy(PGconn *conn);
45984634

45994635
<para>
46004636
A typical application using these functions will have a main loop that
4601-
uses <function>select()</function> or <function>poll()</> to wait for
4637+
uses <function>PQselect()</function> or <function>PQselectExtended()</> to wait for
46024638
all the conditions that it must respond to. One of the conditions
46034639
will be input available from the server, which in terms of
4604-
<function>select()</function> means readable data on the file
4640+
<function>PQselect()</function> means readable data on the file
46054641
descriptor identified by <function>PQsocket</function>. When the main
46064642
loop detects input ready, it should call
46074643
<function>PQconsumeInput</function> to read the input. It can then
@@ -5148,10 +5184,11 @@ typedef struct pgNotify
51485184
useful commands to execute is to call
51495185
<function>PQconsumeInput</function>, then check
51505186
<function>PQnotifies</function>. You can use
5151-
<function>select()</function> to wait for data to arrive from the
5187+
<function>PQselect()</function> or <function>PQselectExtended()</function>
5188+
to wait for data to arrive from the
51525189
server, thereby using no <acronym>CPU</acronym> power unless there is
51535190
something to do. (See <function>PQsocket</function> to obtain the file
5154-
descriptor number to use with <function>select()</function>.) Note that
5191+
descriptor number to use with <function>PQselect()</function>.) Note that
51555192
this will work OK whether you submit commands with
51565193
<function>PQsendQuery</function>/<function>PQgetResult</function> or
51575194
simply use <function>PQexec</function>. You should, however, remember
@@ -8457,12 +8494,10 @@ main(int argc, char **argv)
84578494
while (nnotifies < 4)
84588495
{
84598496
/*
8460-
* Sleep until something happens on the connection. We use select(2)
8461-
* to wait for input, but you could also use poll() or similar
8462-
* facilities.
8497+
* Sleep until something happens on the connection. We use
8498+
* PQselectExtended to wait for input.
84638499
*/
84648500
int sock;
8465-
fd_set input_mask;
84668501

84678502
sock = PQsocket(conn);
84688503

@@ -8472,9 +8507,9 @@ main(int argc, char **argv)
84728507
FD_ZERO(&input_mask);
84738508
FD_SET(sock, &input_mask);
84748509

8475-
if (select(sock + 1, &input_mask, NULL, NULL, NULL) < 0)
8510+
if (PQselectExtended(conn, -1) < 0)
84768511
{
8477-
fprintf(stderr, "select() failed: %s\n", strerror(errno));
8512+
fprintf(stderr, "PQselectExtended() failed: %s\n", strerror(errno));
84788513
exit_nicely(conn);
84798514
}
84808515

0 commit comments

Comments
 (0)