@@ -1376,7 +1376,7 @@ static void msOGRFileOpenSpatialite( layerObj *layer,
1376
1376
1377
1377
char * pszRequest = NULL ;
1378
1378
pszRequest = msStringConcatenate (pszRequest,
1379
- " SELECT * FROM sqlite_master WHERE type = 'table' AND name = lower('" );
1379
+ " SELECT name FROM sqlite_master WHERE type = 'table' AND name = lower('" );
1380
1380
pszRequest = msStringConcatenate (pszRequest, psInfo->pszMainTableName );
1381
1381
pszRequest = msStringConcatenate (pszRequest, " ')" );
1382
1382
OGRLayerH hLayer = OGR_DS_ExecuteSQL ( psInfo->hDS , pszRequest, NULL , NULL );
@@ -1387,7 +1387,13 @@ static void msOGRFileOpenSpatialite( layerObj *layer,
1387
1387
OGRFeatureH hFeature = OGR_L_GetNextFeature (hLayer);
1388
1388
psInfo->bIsOKForSQLCompose = (hFeature != NULL );
1389
1389
if ( hFeature )
1390
+ {
1391
+ msFree (psInfo->pszMainTableName );
1392
+ msFree (psInfo->pszSpatialFilterTableName );
1393
+ psInfo->pszMainTableName = msStrdup ( OGR_F_GetFieldAsString ( hFeature, 0 ) );
1394
+ psInfo->pszSpatialFilterTableName = msStrdup ( psInfo->pszMainTableName );
1390
1395
OGR_F_Destroy (hFeature);
1396
+ }
1391
1397
OGR_DS_ReleaseResultSet ( psInfo->hDS , hLayer );
1392
1398
}
1393
1399
if ( psInfo->bIsOKForSQLCompose )
@@ -1510,6 +1516,7 @@ static void msOGRFileOpenSpatialite( layerObj *layer,
1510
1516
pszRequest = msStringConcatenate (pszRequest, " '" );
1511
1517
1512
1518
psInfo->bHasSpatialIndex = false ;
1519
+ // msDebug("msOGRFileOpen(): %s", pszRequest);
1513
1520
1514
1521
OGRLayerH hLayer = OGR_DS_ExecuteSQL ( psInfo->hDS , pszRequest, NULL , NULL );
1515
1522
if ( hLayer )
0 commit comments