From: | Kelly Burkhart <kelly(dot)burkhart(at)gmail(dot)com> |
---|---|
To: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
Cc: | Peter Geoghegan <peter(dot)geoghegan86(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: libpq sendQuery -- getResult not returning until all queries complete |
Date: | 2010-12-21 19:53:10 |
Message-ID: | AANLkTin0tLm38q42qpa1ERC8YCFTas4aGdLMD=08Zsxq@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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 *res = 0;
PGconn *conn = PQconnectdb( CONNINFO );
if (!conn) fatal("PQconnectdb returned null");
if ( PQstatus(conn) != CONNECTION_OK ) {
PQfinish( conn );
fatal("PQconnectdb failed");
}
if (!PQsendQuery(conn, COMMANDS)) {
PQfinish( conn );
fatal("PQsendQuery failed");
}
while( (res = PQgetResult( conn )) != 0 ) {
printf("retrieved result\n");
PQclear(res);
}
PQfinish( conn );
return 0;
}
On Tue, Dec 21, 2010 at 1:26 PM, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
> On Tue, Dec 21, 2010 at 2:21 PM, Peter Geoghegan
> <peter(dot)geoghegan86(at)gmail(dot)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 is not suggesting that queries run concurrently, but asking why
> result sets can't be popped off as the queries resolve. It's a good
> question; it's probably either a bug in the database or the
> documentation (if it does not turn out to be operator error).
>
> Kelly, if you can produce small test case in C I'll double check it.
>
> merlin
>
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Verite | 2010-12-21 20:07:46 | Re: libpq sendQuery -- getResult not returning until all queries complete |
Previous Message | Kelly Burkhart | 2010-12-21 19:28:23 | Re: libpq sendQuery -- getResult not returning until all queries complete |