From: | Pelle Johansson <morth(at)morth(dot)org> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | PQisBusy returns true but no more data is received. |
Date: | 2006-02-28 18:52:32 |
Message-ID: | 83326227-45CB-42B6-BCD6-2646E037FCAA@morth.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello list,
I'm new here, but didn't see the problem in the archives.
Basically, I have an epoll loop that executes the following code when
I receive data from postgresql (greatly simplified).
int read_sql (PGconn *conn)
{
PGnotify *notice;
PGresult *res;
if (!PQconsumeInput (conn))
return -1;
while (1)
{
while ((notice = PQnotifies (conn)))
{
handle_notice (notice);
PQmemfree (notice);
}
if (PQisBusy (conn))
return 0;
res = PQgetResult (conn);
if (!res)
break;
while ((notice = PQnotifies (conn)))
{
handle_notice (notice);
PQmemfree (notice);
}
handle_result (res);
PQclear (res);
}
handle_query_done (conn);
}
(I've not tried to compile this sample code.)
The SQL query in question is a BEGIN followed by a SELECT (sent in
the same PQsendQuery()).
The problem is that after two iterations in the loop PQisBusy()
returns true, making me exit to the event loop, but no more data is
received, so the function will not be called again. If I disable the
call to PQisBusy() everything works as expected (PQgetResult() will
return NULL on the third iteration). If I move the call to PQisBusy()
outside the loop, everything also works good.
Is it safe to move the call to PQisBusy() outside the loop, or is it
possible that PQgetResult() will block on a long SELECT in that case?
(that would be very bad for me). Or have I misunderstood something
about these functions?
--
Pelle Johansson
From | Date | Subject | |
---|---|---|---|
Next Message | Volkan YAZICI | 2006-02-28 19:16:47 | Re: Breaking Path/Polygon Data into Pieces |
Previous Message | Tom Lane | 2006-02-28 18:14:23 | Re: How many postmasters should be running? |