Skip to content

Commit 0307495

Browse files
committed
[oracle] Fix broken iterator rewind
On behalf of Faunalia, sponsored by ENEL (cherry-picked from d785b90)
1 parent 0c060bd commit 0307495

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/providers/oracle/qgsoraclefeatureiterator.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,16 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature& feature )
209209
if ( mRewind )
210210
{
211211
mRewind = false;
212-
if ( !mQry.first() )
213-
return true;
212+
if ( !QgsOracleProvider::exec( mQry, mSql ) )
213+
{
214+
QgsMessageLog::logMessage( QObject::tr( "Fetching features failed.\nSQL:%1\nError: %2" )
215+
.arg( mQry.lastQuery() )
216+
.arg( mQry.lastError().text() ),
217+
QObject::tr( "Oracle" ) );
218+
return false;
219+
}
214220
}
215-
else if ( !mQry.next() )
221+
if ( !mQry.next() )
216222
{
217223
return false;
218224
}
@@ -444,6 +450,7 @@ bool QgsOracleFeatureIterator::openQuery( QString whereClause )
444450
query += QString( " WHERE %1" ).arg( whereClause );
445451

446452
QgsDebugMsg( QString( "Fetch features: %1" ).arg( query ) );
453+
mSql = query;
447454
if ( !QgsOracleProvider::exec( mQry, query ) )
448455
{
449456
QgsMessageLog::logMessage( QObject::tr( "Fetching features failed.\nSQL:%1\nError: %2" )

src/providers/oracle/qgsoraclefeatureiterator.h

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class QgsOracleFeatureIterator : public QgsAbstractFeatureIteratorFromSource<Qgs
8484
bool mExpressionCompiled;
8585
bool mFetchGeometry;
8686
QgsAttributeList mAttributeList;
87+
QString mSql;
8788
};
8889

8990
#endif // QGSORACLEFEATUREITERATOR_H

0 commit comments

Comments
 (0)