From: Ewan Mellor <em@nexus.co.uk>
To: PostgreSQL Interfaces <pgsql-interfaces@postgresql.org>
Subject: Non-blocking queries using libpq
Date: Wed, 15 Jul 1998 10:19:16 +0100
Message-ID: <35AC7414.12D680B@nexus.co.uk> (raw)
I am having trouble using libpq to query my database in a non-blocking
manner. My test program looks like this:
#include <stdio.h>
#include <libpq-fe.h>
main()
{
PGconn *conn;
PGresult *res;
conn = PQsetdb(NULL, NULL, NULL, NULL, "test");
PQsendQuery(conn, "select * from test_tbl");
while(PQisBusy(conn))
;
res = PQgetResult(conn);
printf("%s.\n", PQgetvalue(res, 0, 0));
PQclear(res);
PQfinish(conn);
return 0;
}
First off, is this OK? (Of course, my real program does things whilst
PQisBusy() and checks for errors etc.)
My problem is that PQisBusy() is never returning FALSE because
conn->asyncStatus is always PGASYNC_BUSY.
PQisBusy() looks like this:
int
PQisBusy(PGconn *conn)
{
if (!conn)
return FALSE;
/* Parse any available data, if our state permits. */
parseInput(conn);
/* PQgetResult will return immediately in all states except BUSY. */
return (conn->asyncStatus == PGASYNC_BUSY);
}
It seems to me that the call to parseInput() will never do anything
because there is no way that data will be read from the backend. Is
that correct? Is the user application supposed to do that?
I am using a snapshot dated a month or two ago.
Thanks in advance,
Ewan Mellor.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: em@nexus.co.uk
Subject: Re: Non-blocking queries using libpq
In-Reply-To: <35AC7414.12D680B@nexus.co.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox