msOGRFileNextShape() not compatible with spatialite views
|Reported by:||Even Rouault||Owned by:||Even Rouault|
Tested with MS4W 3.1.0-beta1.zip which was installed from http://dl.maptools.org/dl/ms4w/ms4w_3.1.0-beta1.zip
Only DATA "table" works as data source for a Mapserver layer. Views or SQL selects do not work when defined as DATA "table_view" or DATA "select geometry from table"
A small test database and corresponding mapfile can be downloaded from http://latuviitta.org/documents/MS_6.2.1_Spatialite_issue.zip Spatialite database is of Spatialite 3.0 version and created with Spatialite-gui 1.5.0. GDAL/OGR has no trouble with the database. """
The root cause is that OGRSQLiteViewLayer::GetUnderlyingLayer?() can emit a CPLError when calling OGRSQLiteDataSource::GetLayerByName?(), that will be hidden by CPLPushErrorHandler(CPLQuietErrorHandler) and properly recoverd by OGR. But the error itself isn't reset, so msOGRFileNextShape() detects it in if( CPLGetLastErrorType() == CE_Failure ) just after calling OGR_L_GetNextFeature().