QgsSpatiaLiteConnection::Error QgsSpatiaLiteConnection::fetchTables( bool loadGeometrylessTables ) { mErrorMsg = QString(); QFileInfo fi( mPath ); if ( !fi.exists() ) { return NotExists; } sqlite3* handle = openSpatiaLiteDb( fi.canonicalFilePath() ); if ( handle == NULL ) { return FailedToOpen; } checkHasMetadataTables( handle ); if ( !mErrorMsg.isNull() ) { // unexpected error; invalid SpatiaLite DB return FailedToCheckMetadata; } if ( !getTableInfo( handle, loadGeometrylessTables ) ) { return FailedToGetTables; } closeSpatiaLiteDb( handle ); return NoError; }
QgsSpatiaLiteConnection::Error QgsSpatiaLiteConnection::fetchTables( bool loadGeometrylessTables ) { mErrorMsg = QString(); QFileInfo fi( mPath ); if ( !fi.exists() ) return NotExists; sqlite3 *handle = openSpatiaLiteDb( fi.canonicalFilePath() ); if ( !handle ) return FailedToOpen; int ret = checkHasMetadataTables( handle ); if ( !mErrorMsg.isNull() || ret == LayoutUnknown ) { // unexpected error; invalid SpatiaLite DB return FailedToCheckMetadata; } bool recentVersion = false; #ifdef SPATIALITE_VERSION_GE_4_0_0 // only if libspatialite version is >= 4.0.0 recentVersion = true; #endif if ( ret == LayoutCurrent && !recentVersion ) { // obsolete library version mErrorMsg = tr( "obsolete libspatialite: connecting to this DB requires using v.4.0 (or any subsequent)" ); return FailedToCheckMetadata; } #ifdef SPATIALITE_VERSION_GE_4_0_0 // only if libspatialite version is >= 4.0.0 // using v.4.0 Abstract Interface if ( !getTableInfoAbstractInterface( handle, loadGeometrylessTables ) ) #else // obsolete library: still using the traditional approach if ( !getTableInfo( handle, loadGeometrylessTables ) ) #endif { return FailedToGetTables; } closeSpatiaLiteDb( handle ); return NoError; }