[QGIS Commit] r13965 - branches/threading-branch/src/providers/postgres

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Jul 26 09:28:58 EDT 2010


Author: wonder
Date: 2010-07-26 13:28:58 +0000 (Mon, 26 Jul 2010)
New Revision: 13965

Modified:
   branches/threading-branch/src/providers/postgres/qgspostgresfeatureiterator.cpp
   branches/threading-branch/src/providers/postgres/qgspostgresfeatureiterator.h
Log:
Cache cursor name in postgres feature iterator


Modified: branches/threading-branch/src/providers/postgres/qgspostgresfeatureiterator.cpp
===================================================================
--- branches/threading-branch/src/providers/postgres/qgspostgresfeatureiterator.cpp	2010-07-26 13:26:36 UTC (rev 13964)
+++ branches/threading-branch/src/providers/postgres/qgspostgresfeatureiterator.cpp	2010-07-26 13:28:58 UTC (rev 13965)
@@ -26,7 +26,7 @@
 {
   P->mConnectionROMutex.lock();
 
-  QString cursorName = QString( "qgisf%1" ).arg( P->providerId );
+  mCursorName = QString( "qgisf%1" ).arg( P->providerId );
 
   QString whereClause;
 
@@ -58,7 +58,7 @@
     whereClause += "(" + P->sqlWhereClause + ")";
   }
 
-  if ( !P->declareCursor( cursorName, fetchAttributes, fetchGeometry, whereClause ) )
+  if ( !P->declareCursor( mCursorName, fetchAttributes, fetchGeometry, whereClause ) )
   {
     mClosed = true;
     return;
@@ -80,11 +80,9 @@
   if ( mClosed )
     return false;
 
-  QString cursorName = QString( "qgisf%1" ).arg( P->providerId );
-
   if ( mFeatureQueue.empty() )
   {
-    QString fetch = QString( "fetch forward %1 from %2" ).arg( mFeatureQueueSize ).arg( cursorName );
+    QString fetch = QString( "fetch forward %1 from %2" ).arg( mFeatureQueueSize ).arg( mCursorName );
     if ( P->connectionRO->PQsendQuery( fetch ) == 0 ) // fetch features asynchronously
     {
       QgsDebugMsg( "PQsendQuery failed" );
@@ -145,7 +143,7 @@
     return false;
 
   //move cursor to first record
-  P->connectionRO->PQexecNR( QString( "move 0 in qgisf%1" ).arg( P->providerId ) );
+  P->connectionRO->PQexecNR( QString( "move 0 in " ) + mCursorName );
 
   mFeatureQueue.empty();
 
@@ -157,7 +155,7 @@
   if ( mClosed )
     return false;
 
-  P->connectionRO->closeCursor( QString( "qgisf%1" ).arg( P->providerId ) );
+  P->connectionRO->closeCursor( mCursorName );
 
   P->mConnectionROMutex.unlock();
 

Modified: branches/threading-branch/src/providers/postgres/qgspostgresfeatureiterator.h
===================================================================
--- branches/threading-branch/src/providers/postgres/qgspostgresfeatureiterator.h	2010-07-26 13:26:36 UTC (rev 13964)
+++ branches/threading-branch/src/providers/postgres/qgspostgresfeatureiterator.h	2010-07-26 13:28:58 UTC (rev 13965)
@@ -32,6 +32,8 @@
 
   int mFetched; // number of retrieved features
 
+  QString mCursorName;
+
   /**
    * Feature queue that GetNextFeature will retrieve from
    * before the next fetch from PostgreSQL



More information about the QGIS-commit mailing list