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

Поиск
Список
Период
Сортировка
От Kelly Burkhart
Тема Re: libpq sendQuery -- getResult not returning until all queries complete
Дата
Msg-id AANLkTin0tLm38q42qpa1ERC8YCFTas4aGdLMD=08Zsxq@mail.gmail.com
обсуждение исходный текст
Ответ на Re: libpq sendQuery -- getResult not returning until all queries complete  (Merlin Moncure <mmoncure@gmail.com>)
Ответы Re: libpq sendQuery -- getResult not returning until all queries complete  ("Daniel Verite" <daniel@manitou-mail.org>)
Список 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@gmail.com> wrote:
> On Tue, Dec 21, 2010 at 2:21 PM, Peter Geoghegan
> <peter.geoghegan86@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 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
>

В списке pgsql-general по дате отправления:

Предыдущее
От: Kelly Burkhart
Дата:
Сообщение: Re: libpq sendQuery -- getResult not returning until all queries complete
Следующее
От: "Daniel Verite"
Дата:
Сообщение: Re: libpq sendQuery -- getResult not returning until all queries complete