File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ QgsPostgresFeatureIterator::QgsPostgresFeatureIterator( QgsPostgresFeatureSource
3535 , mFetched( 0 )
3636 , mFetchGeometry( false )
3737 , mExpressionCompiled( false )
38+ , mLastFetch( false )
3839{
3940 if ( !source->mTransactionConnection )
4041 {
@@ -119,7 +120,7 @@ bool QgsPostgresFeatureIterator::fetchFeature( QgsFeature& feature )
119120 if ( mClosed )
120121 return false ;
121122
122- if ( mFeatureQueue .empty () )
123+ if ( mFeatureQueue .empty () && ! mLastFetch )
123124 {
124125 QString fetch = QString ( " FETCH FORWARD %1 FROM %2" ).arg ( mFeatureQueueSize ).arg ( mCursorName );
125126 QgsDebugMsgLevel ( QString ( " fetching %1 features." ).arg ( mFeatureQueueSize ), 4 );
@@ -145,6 +146,8 @@ bool QgsPostgresFeatureIterator::fetchFeature( QgsFeature& feature )
145146 if ( rows == 0 )
146147 continue ;
147148
149+ mLastFetch = rows < mFeatureQueueSize ;
150+
148151 for ( int row = 0 ; row < rows; row++ )
149152 {
150153 mFeatureQueue .enqueue ( QgsFeature () );
@@ -323,7 +326,6 @@ QString QgsPostgresFeatureIterator::whereClauseRect()
323326bool QgsPostgresFeatureIterator::declareCursor ( const QString& whereClause )
324327{
325328 mFetchGeometry = !( mRequest .flags () & QgsFeatureRequest::NoGeometry ) && !mSource ->mGeometryColumn .isNull ();
326-
327329#if 0
328330 // TODO: check that all field indexes exist
329331 if ( !hasAllFields )
@@ -432,6 +434,7 @@ bool QgsPostgresFeatureIterator::declareCursor( const QString& whereClause )
432434 return false ;
433435 }
434436
437+ mLastFetch = false ;
435438 return true ;
436439}
437440
Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ class QgsPostgresFeatureIterator : public QgsAbstractFeatureIteratorFromSource<Q
125125 virtual bool providerCanSimplify ( QgsSimplifyMethod::MethodType methodType ) const override ;
126126
127127 bool mExpressionCompiled ;
128+ bool mLastFetch ;
128129};
129130
130131#endif // QGSPOSTGRESFEATUREITERATOR_H
You can’t perform that action at this time.
0 commit comments