mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
In PQnotifies discussion, reference PQsocket as function needed to get
file descriptor number for select(). (Suggestion from Ken Wright.)
This commit is contained in:
@ -1460,13 +1460,17 @@ deprecated as a waste of processing power.
|
|||||||
<para>
|
<para>
|
||||||
A better way to check for NOTIFY
|
A better way to check for NOTIFY
|
||||||
messages when you have no useful queries to make is to call
|
messages when you have no useful queries to make is to call
|
||||||
<function>PQconsumeInput()</function>, then check <function>PQnotifies()</function>.
|
<function>PQconsumeInput()</function>, then check
|
||||||
|
<function>PQnotifies()</function>.
|
||||||
You can use <function>select</function>(2) to wait for backend data to
|
You can use <function>select</function>(2) to wait for backend data to
|
||||||
arrive, thereby using no <acronym>CPU</acronym> power unless there is something
|
arrive, thereby using no <acronym>CPU</acronym> power unless there is something
|
||||||
to do. Note that this will work OK whether you use <function>PQsendQuery</function>/
|
to do. (See <function>PQsocket()</function> to obtain the file descriptor
|
||||||
<function>PQgetResult</function> or simply <function>PQexec</function> for
|
number to use with <function>select</function>.)
|
||||||
queries. You should, however, remember to check <function>PQnotifies()</function>
|
Note that this will work OK whether you submit queries with
|
||||||
after each <function>PQgetResult</function> or <function>PQexec</function> to see
|
<function>PQsendQuery</function>/<function>PQgetResult</function> or simply
|
||||||
|
use <function>PQexec</function>. You should, however, remember to
|
||||||
|
check <function>PQnotifies()</function> after each
|
||||||
|
<function>PQgetResult</function> or <function>PQexec</function>, to see
|
||||||
if any notifications came in during the processing of the query.
|
if any notifications came in during the processing of the query.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user