Opened 4 years ago

Closed 4 years ago

#5278 closed defect (fixed)

mbtiles - MBTilesGetBandCount - second SELECT Query never called when needed

Reported by: mj10777 Owned by: warmerdam
Priority: high Milestone: 1.10.2
Component: GDAL_Raster Version:
Severity: critical Keywords: mbtiles
Cc:

Description

In mbtilesdataset.cpp Function: MBTilesGetBandCount

a second SELECT Query should be called when the first Query brings no results.

Condition for this is 'if (hSQLLyr == NULL)'

  • when the first Query fails, hSQLLyr is not set to NULL and therefore never NULL
if (fpCURLOGR)
{
 if (nBands != -1)
 { // ... when hSQLLyr is no longer needed, set to NULL
 }
 else
 {
  if (CPLGetLastErrorType() == CE_Failure)
  {
   hSQLLyr = NULL; // this is needed, the message is not
   CPLError(CE_Failure, CPLGetLastErrorNo(), "%s", ...
  }
 }
}
else
{
 hSQLLyr = OGR_DS_ExecuteSQL(hDS, pszSQL, NULL, NULL);
 // the following is needed
 if (CPLGetLastErrorType() == CE_Failure)
 {
  hSQLLyr = NULL;
 }
}
if (hSQLLyr == NULL)
{ // this will now be called
 pszSQL = CPLSPrintf("SELECT tile_data FROM tiles WHERE zoom_level = %d LIMIT 1", nMaxLevel);
 ...
}

This is needed for mbtiles files, where the zooms levels have not been completely filled.

This, otherwise correct, mbtiles file will fail:

gdalinfo /vsicurl/http://www.mj10777.de/public/download/mbtiles/1867.Berlin_Liebenow.mbtiles

With the above correction, it will show correctly.

Mark Johnson, Berlin Germany

Change History (1)

comment:1 Changed 4 years ago by Even Rouault

Component: defaultGDAL_Raster
Milestone: 1.10.2
Resolution: fixed
Status: newclosed
Version: svn-trunk

Fixed in trunk (r26562) and branches/1.10 (r26563)

Note: See TracTickets for help on using tickets.