From: | Iker Arizmendi <iker(at)research(dot)att(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | rfc - libpq extensions |
Date: | 2003-01-10 17:10:01 |
Message-ID: | 20030110121001.57f469ee.iker@research.att.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Currently libpq doesn't allow you to call PQsendQuery multiple
times in succession over an asynchronous connection. If libpq could
accept concurrent queries (with 1 or more SQL statements each) then
code functionally similiar to the following would come in handy (at
least to me :)
// hypothetical PGquery object maintains the state
// for a given query and allows for selective query
// cancellation
PGquery* pQuery1 = PQcreateQuery("SELECT...");
PGquery* pQuery2 = PQcreateQuery("UPDATE...");
PGquery* pQuery3 = PQcreateQuery("INSERT...");
PQconnExecute(pConn, pQuery1);
PQconnExecute(pConn, pQuery2);
PQconnExecute(pConn, pQuery3);
// event loop
while(1)
{
poll(...)
PQconsumeInput(pConn);
// hypothetical PQqueryState
if (PQqueryState(pQuery1) == PQ_QUERY_COMPLETE) {
// process results
}
if (PQqueryState(pQuery2) == PQ_QUERY_COMPLETE) {
// process results
}
if (PQqueryState(pQuery3) == PQ_QUERY_COMPLETE) {
// process results
}
}
As things stand now you have to wait for each query to finish before
issuing a new one. This poses some difficulties if you want to use
connection pooling in an event driven server (as I'm trying to do). In
particular, you have to perform your own queueing of queries while you
wait for a connection to become available. To deal with this issue I've
started work on some extensions to libpq to allow for both
multiple"in-flight" queries and support for connection pooling while
still providing support for the usual access techniques. I was hoping to
get some thoughts from folks on the list with regard to interest
in these features (and/or potential pitfalls).
Regards,
Iker
From | Date | Subject | |
---|---|---|---|
Next Message | Neil Conway | 2003-01-10 17:15:35 | Re: rfc - libpq extensions |
Previous Message | scott.marlowe | 2003-01-10 16:23:53 | persistant transactions |