Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-22 Thread Kelly Burkhart
On Tue, Dec 21, 2010 at 6:11 PM, Tom Lane t...@sss.pgh.pa.us wrote: Merlin Moncure mmonc...@gmail.com writes: On Tue, Dec 21, 2010 at 6:49 PM, Tom Lane t...@sss.pgh.pa.us wrote: If you just unconditionally flush there, it will result in an extra network message in the normal case where there's

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-22 Thread Merlin Moncure
On Wed, Dec 22, 2010 at 10:07 AM, Kelly Burkhart kelly.burkh...@gmail.com wrote: On Tue, Dec 21, 2010 at 6:11 PM, Tom Lane t...@sss.pgh.pa.us wrote: Merlin Moncure mmonc...@gmail.com writes: On Tue, Dec 21, 2010 at 6:49 PM, Tom Lane t...@sss.pgh.pa.us wrote: If you just unconditionally flush

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-22 Thread Kelly Burkhart
On Wed, Dec 22, 2010 at 9:18 AM, Merlin Moncure mmonc...@gmail.com wrote: On Wed, Dec 22, 2010 at 10:07 AM, Kelly Burkhart kelly.burkh...@gmail.com wrote: On Tue, Dec 21, 2010 at 6:11 PM, Tom Lane t...@sss.pgh.pa.us wrote: Merlin Moncure mmonc...@gmail.com writes: On Tue, Dec 21, 2010 at 6:49

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-22 Thread Merlin Moncure
On Wed, Dec 22, 2010 at 11:38 AM, Kelly Burkhart kelly.burkh...@gmail.com wrote: On Wed, Dec 22, 2010 at 10:19 AM, Merlin Moncure mmonc...@gmail.com wrote: have you ruled out sending all the data you need to send into say, a plpgsal function and doing the work there? Not sure that would do

[GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Kelly Burkhart
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

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Peter Geoghegan
You can't concurrently execute queries from within a single connection. Perhaps you should use multiple connections, while understanding the implications of having each operate within a separate snapshot. Don't forget to free memory with PQclear() . I guess you omitted that because it's just

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Merlin Moncure
On Tue, Dec 21, 2010 at 2:21 PM, Peter Geoghegan peter.geoghega...@gmail.com wrote: You can't concurrently execute queries from within a single connection. Perhaps you should use multiple connections, while understanding the implications of having each operate within a separate snapshot. OP

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Kelly Burkhart
Yes, I omitted the PQclear for simplicity. I'm not concurrently executing queries, I'm sending multiple queries to be executed serially by the backend. I'm expecting the server to send me the PQresult objects as each query completes rather than sending them all *after* all of the queries have

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Kelly Burkhart
This should do it: #include stdio.h #include stdlib.h #include libpq-fe.h #define CONNINFO your info here #define COMMANDS select current_timestamp; select pg_sleep(5); select current_timestamp void fatal( const char *msg ) { fprintf( stderr, %s\n, msg ); exit(1); } int main() { PGresult

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Daniel Verite
Kelly Burkhart wrote: #define COMMANDS select current_timestamp; select pg_sleep(5); select current_timestamp You should use current_clock() instead of current_timestamp, because current_timestamp returns a fixed value throughout a transaction. Best regards, -- Daniel

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Merlin Moncure
On Tue, Dec 21, 2010 at 3:07 PM, Daniel Verite dan...@manitou-mail.org wrote:        Kelly Burkhart wrote: #define COMMANDS select current_timestamp; select pg_sleep(5); select current_timestamp You should use current_clock() instead of current_timestamp, because current_timestamp returns a

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Merlin Moncure
On Tue, Dec 21, 2010 at 3:14 PM, Merlin Moncure mmonc...@gmail.com wrote: On Tue, Dec 21, 2010 at 3:07 PM, Daniel Verite dan...@manitou-mail.org wrote:        Kelly Burkhart wrote: #define COMMANDS select current_timestamp; select pg_sleep(5); select current_timestamp You should use

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Merlin Moncure
On Tue, Dec 21, 2010 at 3:37 PM, Merlin Moncure mmonc...@gmail.com wrote: On Tue, Dec 21, 2010 at 3:14 PM, Merlin Moncure mmonc...@gmail.com wrote: On Tue, Dec 21, 2010 at 3:07 PM, Daniel Verite dan...@manitou-mail.org wrote:        Kelly Burkhart wrote: #define COMMANDS select

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Merlin Moncure
On Tue, Dec 21, 2010 at 3:40 PM, Merlin Moncure mmonc...@gmail.com wrote: On Tue, Dec 21, 2010 at 3:37 PM, Merlin Moncure mmonc...@gmail.com wrote: On Tue, Dec 21, 2010 at 3:14 PM, Merlin Moncure mmonc...@gmail.com wrote: On Tue, Dec 21, 2010 at 3:07 PM, Daniel Verite dan...@manitou-mail.org

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Tom Lane
Merlin Moncure mmonc...@gmail.com writes: hm, a pq_flush() after command completion putmessage in backend/tcop/dest.c seems to fix the problem. I'll send up a patch to -hackers. They might backpatch it, unless there is a good reason not to do this (I can't think of any). If you just

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Merlin Moncure
On Tue, Dec 21, 2010 at 6:49 PM, Tom Lane t...@sss.pgh.pa.us wrote: Merlin Moncure mmonc...@gmail.com writes: hm, a pq_flush() after command completion putmessage in backend/tcop/dest.c seems to fix the problem.  I'll send up a patch to -hackers.  They might backpatch it, unless there is a

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Tom Lane
Merlin Moncure mmonc...@gmail.com writes: On Tue, Dec 21, 2010 at 6:49 PM, Tom Lane t...@sss.pgh.pa.us wrote: If you just unconditionally flush there, it will result in an extra network message in the normal case where there's not another query to do.  The current code is designed not to flush