rfc - libpq extensions
От | Iker Arizmendi |
---|---|
Тема | rfc - libpq extensions |
Дата | |
Msg-id | 20030110121001.57f469ee.iker@research.att.com обсуждение исходный текст |
Ответы |
Re: rfc - libpq extensions
|
Список | 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
В списке pgsql-general по дате отправления: