Permalink
Browse files

OGR Spatialite: do not be case sensitive if DATA is a SELECT ... FROM…

… table_name
1 parent 45037eb commit 491397c126ebec3e8a97f5c91e018546cc168fcf @rouault rouault committed Dec 3, 2016
Showing with 8 additions and 1 deletion.
  1. +8 −1 mapogr.cpp
View
@@ -1376,7 +1376,7 @@ static void msOGRFileOpenSpatialite( layerObj *layer,
char* pszRequest = NULL;
pszRequest = msStringConcatenate(pszRequest,
- "SELECT * FROM sqlite_master WHERE type = 'table' AND name = lower('");
+ "SELECT name FROM sqlite_master WHERE type = 'table' AND name = lower('");
pszRequest = msStringConcatenate(pszRequest, psInfo->pszMainTableName);
pszRequest = msStringConcatenate(pszRequest, "')");
OGRLayerH hLayer = OGR_DS_ExecuteSQL( psInfo->hDS, pszRequest, NULL, NULL );
@@ -1387,7 +1387,13 @@ static void msOGRFileOpenSpatialite( layerObj *layer,
OGRFeatureH hFeature = OGR_L_GetNextFeature(hLayer);
psInfo->bIsOKForSQLCompose = (hFeature != NULL);
if( hFeature )
+ {
+ msFree(psInfo->pszMainTableName);
+ msFree(psInfo->pszSpatialFilterTableName);
+ psInfo->pszMainTableName = msStrdup( OGR_F_GetFieldAsString( hFeature, 0) );
+ psInfo->pszSpatialFilterTableName = msStrdup( psInfo->pszMainTableName );
OGR_F_Destroy(hFeature);
+ }
OGR_DS_ReleaseResultSet( psInfo->hDS, hLayer );
}
if( psInfo->bIsOKForSQLCompose )
@@ -1510,6 +1516,7 @@ static void msOGRFileOpenSpatialite( layerObj *layer,
pszRequest = msStringConcatenate(pszRequest, "'");
psInfo->bHasSpatialIndex = false;
+ //msDebug("msOGRFileOpen(): %s", pszRequest);
OGRLayerH hLayer = OGR_DS_ExecuteSQL( psInfo->hDS, pszRequest, NULL, NULL );
if( hLayer )

0 comments on commit 491397c

Please sign in to comment.