Re: Speed dblink using alternate libpq tuple storage
| От | Marko Kreen |
|---|---|
| Тема | Re: Speed dblink using alternate libpq tuple storage |
| Дата | |
| Msg-id | 20120226221922.GA6981@gmail.com обсуждение исходный текст |
| Ответ на | Re: Speed dblink using alternate libpq tuple storage (Marko Kreen <markokr@gmail.com>) |
| Список | pgsql-hackers |
On Fri, Feb 24, 2012 at 05:46:16PM +0200, Marko Kreen wrote:
> - rename to PQrecvRow() and additionally provide PQgetRow()
I tried it and it seems to work as API - there is valid behaviour
for both sync and async connections.
Sync connection - PQgetRow() waits for data from network:
if (!PQsendQuery(db, q))
die(db, "PQsendQuery");
while (1) {
r = PQgetRow(db);
if (!r)
break;
handle(r);
PQclear(r);
}
r = PQgetResult(db);
Async connection - PQgetRow() does PQisBusy() loop internally,
but does not read from network:
on read event:
PQconsumeInput(db);
while (1) {
r = PQgetRow(db);
if (!r)
break;
handle(r);
PQclear(r);
}
if (!PQisBusy(db))
r = PQgetResult(db);
else
waitForMoredata();
As it seems to simplify life for quite many potential users,
it seems worth including in libpq properly.
Attached patch is on top of v20120223 of row-processor
patch. Only change in general code is allowing
early exit for syncronous connection, as we now have
valid use-case for it.
--
marko
Вложения
В списке pgsql-hackers по дате отправления: