<para>
<function>PQnotifies</function> does not actually read data from the
server; it just returns messages previously absorbed by another
- <application>libpq</application> function. In prior releases of
+ <application>libpq</application> function. In ancient releases of
<application>libpq</application>, the only way to ensure timely receipt
of <command>NOTIFY</> messages was to constantly submit commands, even
empty ones, and then check <function>PQnotifies</function> after each
notify->relname, notify->be_pid);
PQfreemem(notify);
nnotifies++;
+ PQconsumeInput(conn);
}
}
{
PGnotify *notify;
- while ((notify = PQnotifies(pset.db)))
+ PQconsumeInput(pset.db);
+ while ((notify = PQnotifies(pset.db)) != NULL)
{
/* for backward compatibility, only show payload if nonempty */
if (notify->extra[0])
notify->relname, notify->be_pid);
fflush(pset.queryFout);
PQfreemem(notify);
+ PQconsumeInput(pset.db);
}
}
}
/* check for asynchronous returns */
- notify = PQnotifies(stmt->connection->connection);
- if (notify)
+ PQconsumeInput(stmt->connection->connection);
+ while ((notify = PQnotifies(stmt->connection->connection)) != NULL)
{
ecpg_log("ecpg_process_output on line %d: asynchronous notification of \"%s\" from backend PID %d received\n",
stmt->lineno, notify->relname, notify->be_pid);
PQfreemem(notify);
+ PQconsumeInput(stmt->connection->connection);
}
return status;
* no unhandled async notification from the backend
*
* the CALLER is responsible for FREE'ing the structure returned
+ *
+ * Note that this function does not read any new data from the socket;
+ * so usually, caller should call PQconsumeInput() first.
*/
PGnotify *
PQnotifies(PGconn *conn)
notify->relname, notify->be_pid);
PQfreemem(notify);
nnotifies++;
+ PQconsumeInput(conn);
}
}