[Libpqxx-general] pqxx::pipeline as a means of "posting" a call to a pl/pgSQL function
Peter Geoghegan
peter.geoghegan86 at gmail.com
Sun Jun 8 20:31:35 UTC 2008
Hello,
Per JTV's suggestion, I've been reading the doxygen documentation for
pqxx::pipeline, as well as the related demo/test program's source,
with a view to using a pipeline to avoid having to wait for a pl/pgSQL
function which might take a while to return, holding up my application
and making its GUI unresponsive. However, some things are still
unclear. In the case of the pl/pgSQL functions, I don't care about the
result. In other cases (typically raw SELECT queries), I do.
I've been using a non-transaction, because any time I need
transactional integrity, I get it from doing my work within pl/pgSQL
functions anyway. The non-transaction lasts the duration of the
program's execution - all database work goes through it.
I am considering doing the following. Please give opinions on this approach:
I will continue to make SELECT statements, the most common sort of
query in my application (they don't require transactional integrity)
directly on my pervasive non-transaction object on the heap.
When the time comes to call my pl/pgSQL function, something that
occurs much less frequently then the SELECT queries, I use my
program's pipeline object, which is also on the heap. I call its
complete() , just in case it hasn't finished from last time
(unlikely), and I then call its flush(), so that my pipeline doesn't
eventually end up containing a whole bunch of pqxx::result containers
that just contain voids. Finally, I call its insert(const
PGSTD::string& q), and insert my query. It's possible, though
unlikely, that the program would attempt to do another raw SELECT on
the non-transaction object itself *before* the pl/pgSQL function
called by the pipeline acting on that same non-transaction returns. Is
this dangerous or impossible? Should I just do *everything* with the
pipeline, and call its insert(const PGSTD::string& q) followed by its
retrieve( query_id qid) for the raw SELECT queries?
I have another concern. The pipeline class is implied to be unstable,
as it is not "a stable part of the library". Is it unstable in the
sense that it is subject to change, or in the sense that it is liable
to cause problems, or both? Do you think that it would be reasonable
to use it in a production system? These queries should never throw
exceptions.
Regards,
Peter Geoghegan
More information about the Libpqxx-general
mailing list