[Qgis-developer] Connection reusing in postgres provider
Marco Hugentobler
marco.hugentobler at karto.baug.ethz.ch
Sun Mar 9 12:15:56 EDT 2008
Hi Jürgen,
Sorry to spam you with another mail today.
There is a problem with the reusage of connections in postgres provider (via
static member variable QgsPostgresProvider::connections). Two postgres layers
that share the same connection might influence each others binary cursors. As
a binary cursors is valid inside a transaction, calling "end work" on a
connection will also influence the cursor of the second layer.
Independence of the binary cursors is particularly important in geoprocessing,
where situations like in the following Pseudocode happen very often:
QgsVectorDataProvider* pa;
QgsVectorDataProvider*pb;
pa->select
pb->select
while(pb->getNextFeature)
{
QgsRect boundingBox = feature.boundingBox;
pa->select(boundingBox)
while(pa->getNextFeature)
{
}
}
For a test, I changed the static connections variable to a nonstatic one (so
disabled the connection sharing) and the problems in the geoprocessing plugin
went away.
Do you think connection sharing in postgres provider should be disabled?
Or is there a possibility to prevent the binary cursor problem with keeping
connection sharing?
Regards,
Marco
--
Dr. Marco Hugentobler
Institute of Cartography
ETH Zurich
Technical Advisor QGIS Project Steering Committee
More information about the Qgis-developer
mailing list