libpq sendQuery -- getResult not returning until all queries complete

From: Kelly Burkhart <kelly(dot)burkhart(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: libpq sendQuery -- getResult not returning until all queries complete
Date: 2010-12-21 18:42:40
Message-ID: AANLkTik4zFQsB+iZyi-h95qpeBHJ+Qe0kFO9xaHU+A-e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello, I'm sending a group of queries to the database with PQsendQuery
and using PQgetResult to return results similar to this:

PQsendQuery( "select current_timestamp; select pg_sleep(1); select
current_timestamp" );

while( result = PQgetResult() )
doSomethingWith( result )

I'm finding that PQgetResult() will not return the first result until
all three results are ready. In real life I would be sending
consequential queries and would like the front end to be processing
one result while the backend is producing the next one. The
documentation for PQgetResult in section 30.4 of the 8.4.5 manual
suggests that this is what should happen.

Can anyone explain if sendQuery/getResult is intended to work as
documented? And if so what my problem may be? (perhaps my pg_sleep
is preventing the first result from being written?)

Thanks,

-Kelly

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tomas Vondra 2010-12-21 18:50:57 Re: Can the query planner create indexes?
Previous Message Richard Broersma 2010-12-21 18:18:07 Re: Constraining overlapping date ranges