@@ -5182,36 +5182,24 @@ QGISEXTERN bool deleteLayer( const QString& dbPath, const QString& tableName, QS
5182
5182
return false ;
5183
5183
}
5184
5184
sqlite3* sqlite_handle = hndl->handle ();
5185
-
5185
+ int ret;
5186
5186
#ifdef SPATIALITE_VERSION_GE_4_0_0
5187
5187
// only if libspatialite version is >= 4.0.0
5188
+ // if libspatialite is v.4.0 (or higher) using the internal library
5189
+ // method is highly recommended
5190
+ if ( !gaiaDropTable ( sqlite_handle, tableName.toUtf8 ().constData () ) )
5188
5191
{
5189
- // if libspatialite is v.4.0 (or higher) using the internal library
5190
- // method is highly recommended
5191
- if ( !gaiaDropTable ( sqlite_handle, tableName.toUtf8 ().constData () ) )
5192
- {
5193
- // unexpected error
5194
- errCause = QObject::tr ( " Unable to delete table %1\n " ).arg ( tableName );
5195
- QgsSpatiaLiteProvider::SqliteHandles::closeDb ( hndl );
5196
- return false ;
5197
- }
5198
- // run VACUUM to free unused space and compact the database
5199
- int ret = sqlite3_exec ( sqlite_handle, " VACUUM" , NULL , NULL , NULL );
5200
- if ( ret != SQLITE_OK )
5201
- {
5202
- QgsDebugMsg ( " Failed to run VACUUM after deleting table on database " + dbPath );
5203
- }
5192
+ // unexpected error
5193
+ errCause = QObject::tr ( " Unable to delete table %1\n " ).arg ( tableName );
5204
5194
QgsSpatiaLiteProvider::SqliteHandles::closeDb ( hndl );
5205
- return true ;
5195
+ return false ;
5206
5196
}
5207
- #endif
5208
-
5197
+ #else
5209
5198
// drop the table
5210
-
5211
5199
QString sql = QString ( " DROP TABLE " ) + QgsSpatiaLiteProvider::quotedIdentifier ( tableName );
5212
5200
QgsDebugMsg ( sql );
5213
5201
char *errMsg = NULL ;
5214
- int ret = sqlite3_exec ( sqlite_handle, sql.toUtf8 ().constData (), NULL , NULL , &errMsg );
5202
+ ret = sqlite3_exec ( sqlite_handle, sql.toUtf8 ().constData (), NULL , NULL , &errMsg );
5215
5203
if ( ret != SQLITE_OK )
5216
5204
{
5217
5205
errCause = QObject::tr ( " Unable to delete table %1:\n " ).arg ( tableName );
@@ -5229,11 +5217,11 @@ QGISEXTERN bool deleteLayer( const QString& dbPath, const QString& tableName, QS
5229
5217
{
5230
5218
QgsDebugMsg ( " sqlite error: " + QString::fromUtf8 ( sqlite3_errmsg ( sqlite_handle ) ) );
5231
5219
}
5220
+ #endif
5232
5221
5233
5222
// TODO: remove spatial indexes?
5234
-
5235
5223
// run VACUUM to free unused space and compact the database
5236
- ret = sqlite3_exec ( sqlite_handle, " VACUUM" , NULL , NULL , &errMsg );
5224
+ ret = sqlite3_exec ( sqlite_handle, " VACUUM" , NULL , NULL , NULL );
5237
5225
if ( ret != SQLITE_OK )
5238
5226
{
5239
5227
QgsDebugMsg ( " Failed to run VACUUM after deleting table on database " + dbPath );
0 commit comments