Asynchronous Query processing

From: "Brendon Sablinski" <mapletide(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Asynchronous Query processing
Date: 2007-08-06 11:53:17
Message-ID: 9950c73c0708060453t4dc9bc05g53d84abe3e1c97eb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a need to do asynchronous query processing. I am a little confused
by the order and frequency of calls. Can someone tell me if the below is
correct? The code comments are littered with my questions.

PQsendQueryParams(pgconn, "SELECT ..", ....);

while(1)
{
epoll/poll/select PQsocket(pgconn) [read]

// call this each time poll indicates data is ready?
PQconsumeInput(pgconn);

// If isBusy returns 1, just poll again? Will this indicate 0 when I have
a full PGResult set?
// Or, can it split the results of a single statement across multiple
result sets.
if(PQisBusy())
conitnue;

// I know the docs say keep calling getResult until it returns NULL. In
my
// case, I am wondering if that is needed. I only send one statement at a
// time to the server. The connection is not listening for notifies
either. Do
// I still need to call getResult multiple times? I saw many examples
online
// that DO NOT call it multiple times, all of them executed a single
statement.
res = PQgetResult(pgconn);

process_results(res);
}

thanks, brendon

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Reinhard Max 2007-08-06 11:59:48 Re: Suse RPM's
Previous Message novnov 2007-08-06 11:42:25 Re: Postgres 8.2 binary for ubuntu 6.10?