@@ -475,8 +475,6 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
475475 bool alreadyDone = false ;
476476 bool ret = false ;
477477
478- #ifdef SPATIALITE_VERSION_GE_4_0_0
479- // only if libspatialite version is >= 4.0.0
480478 gaiaVectorLayersListPtr list = nullptr ;
481479 gaiaVectorLayerPtr lyr = nullptr ;
482480 bool specialCase = false ;
@@ -500,7 +498,6 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
500498 QgsDebugMsg ( " Using checkLayerTypeAbstractInterface" );
501499 alreadyDone = true ;
502500 }
503- #endif
504501
505502 if ( !alreadyDone )
506503 {
@@ -533,7 +530,6 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
533530
534531 alreadyDone = false ;
535532
536- #ifdef SPATIALITE_VERSION_GE_4_0_0
537533 if ( lyr )
538534 {
539535 // using the v.4.0 AbstractInterface
@@ -559,7 +555,6 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
559555 gaiaFreeVectorLayersList ( list );
560556 alreadyDone = true ;
561557 }
562- #endif
563558
564559 if ( !alreadyDone )
565560 {
@@ -665,9 +660,6 @@ static TypeSubType getVariantType( const QString &type )
665660 return TypeSubType ( QVariant::String, QVariant::Invalid );
666661}
667662
668- #ifdef SPATIALITE_VERSION_GE_4_0_0
669- // only if libspatialite version is >= 4.0.0
670-
671663void QgsSpatiaLiteProvider::loadFieldsAbstractInterface ( gaiaVectorLayerPtr lyr )
672664{
673665 if ( !lyr )
@@ -774,7 +766,6 @@ void QgsSpatiaLiteProvider::loadFieldsAbstractInterface( gaiaVectorLayerPtr lyr
774766
775767 sqlite3_free_table ( results );
776768}
777- #endif
778769
779770QString QgsSpatiaLiteProvider::spatialiteVersion ()
780771{
@@ -4185,16 +4176,9 @@ bool QgsSpatiaLiteProvider::addAttributes( const QList<QgsField> &attributes )
41854176 handleError ( sql, errMsg, true );
41864177 return false ;
41874178 }
4188- #ifdef SPATIALITE_VERSION_GE_4_0_0
4189- sql = QStringLiteral ( " UPDATE geometry_columns_statistics set last_verified = 0 WHERE f_table_name=\" %1\" AND f_geometry_column=\" %2\" ;" )
4190- .arg ( mTableName ,
4191- mGeometryColumn );
4192- ret = sqlite3_exec ( mSqliteHandle , sql.toUtf8 ().constData (), nullptr , nullptr , &errMsg );
4193- update_layer_statistics ( mSqliteHandle , mTableName .toUtf8 ().constData (), mGeometryColumn .toUtf8 ().constData () );
4194- #elif SPATIALITE_VERSION_G_4_1_1
4195- gaiaStatisticsInvalidate ( mSqliteHandle , tableName.toUtf8 ().constData (), mGeometryColumn .toUtf8 ().constData () );
4179+
4180+ gaiaStatisticsInvalidate ( mSqliteHandle , mTableName .toUtf8 ().constData (), mGeometryColumn .toUtf8 ().constData () );
41964181 update_layer_statistics ( mSqliteHandle , mTableName .toUtf8 ().constData (), mGeometryColumn .toUtf8 ().constData () );
4197- #endif
41984182
41994183 // reload columns
42004184 loadFields ();
@@ -4401,8 +4385,6 @@ QString QgsSpatiaLiteProvider::quotedValue( QString value )
44014385 return value.prepend ( ' \' ' ).append ( ' \' ' );
44024386}
44034387
4404- #ifdef SPATIALITE_VERSION_GE_4_0_0
4405- // only if libspatialite version is >= 4.0.0
44064388bool QgsSpatiaLiteProvider::checkLayerTypeAbstractInterface ( gaiaVectorLayerPtr lyr )
44074389{
44084390 if ( !lyr )
@@ -4444,7 +4426,6 @@ bool QgsSpatiaLiteProvider::checkLayerTypeAbstractInterface( gaiaVectorLayerPtr
44444426
44454427 return true ;
44464428}
4447- #endif
44484429
44494430bool QgsSpatiaLiteProvider::checkLayerType ()
44504431{
@@ -4626,8 +4607,6 @@ bool QgsSpatiaLiteProvider::checkLayerType()
46264607 return count == 1 ;
46274608}
46284609
4629- #ifdef SPATIALITE_VERSION_GE_4_0_0
4630- // only if libspatialite version is >= 4.0.0
46314610bool QgsSpatiaLiteProvider::getGeometryDetailsAbstractInterface ( gaiaVectorLayerPtr lyr )
46324611{
46334612 if ( !lyr )
@@ -4728,7 +4707,6 @@ void QgsSpatiaLiteProvider::getViewSpatialIndexName()
47284707 }
47294708 sqlite3_free_table ( results );
47304709}
4731- #endif
47324710
47334711bool QgsSpatiaLiteProvider::getGeometryDetails ()
47344712{
@@ -5143,8 +5121,6 @@ bool QgsSpatiaLiteProvider::getSridDetails()
51435121 return true ;
51445122}
51455123
5146- #ifdef SPATIALITE_VERSION_GE_4_0_0
5147- // only if libspatialite version is >= 4.0.0
51485124bool QgsSpatiaLiteProvider::getTableSummaryAbstractInterface ( gaiaVectorLayerPtr lyr )
51495125{
51505126 if ( !lyr )
@@ -5164,7 +5140,6 @@ bool QgsSpatiaLiteProvider::getTableSummaryAbstractInterface( gaiaVectorLayerPtr
51645140
51655141 return true ;
51665142}
5167- #endif
51685143
51695144bool QgsSpatiaLiteProvider::getTableSummary ()
51705145{
@@ -5389,41 +5364,13 @@ QGISEXTERN bool deleteLayer( const QString &dbPath, const QString &tableName, QS
53895364 }
53905365 sqlite3 *sqlite_handle = hndl->handle ();
53915366 int ret;
5392- #ifdef SPATIALITE_VERSION_GE_4_0_0
5393- // only if libspatialite version is >= 4.0.0
5394- // if libspatialite is v.4.0 (or higher) using the internal library
5395- // method is highly recommended
53965367 if ( !gaiaDropTable ( sqlite_handle, tableName.toUtf8 ().constData () ) )
53975368 {
53985369 // unexpected error
53995370 errCause = QObject::tr ( " Unable to delete table %1\n " ).arg ( tableName );
54005371 QgsSqliteHandle::closeDb ( hndl );
54015372 return false ;
54025373 }
5403- #else
5404- // drop the table
5405- QString sql = QString ( " DROP TABLE " ) + QgsSpatiaLiteProvider::quotedIdentifier ( tableName );
5406- QgsDebugMsg ( sql );
5407- char *errMsg = nullptr ;
5408- ret = sqlite3_exec ( sqlite_handle, sql.toUtf8 ().constData (), nullptr , nullptr , &errMsg );
5409- if ( ret != SQLITE_OK )
5410- {
5411- errCause = QObject::tr ( " Unable to delete table %1:\n " ).arg ( tableName );
5412- errCause += QString::fromUtf8 ( errMsg );
5413- sqlite3_free ( errMsg );
5414- QgsSqliteHandle::closeDb ( hndl );
5415- return false ;
5416- }
5417-
5418- // remove table from geometry columns
5419- sql = QString ( " DELETE FROM geometry_columns WHERE upper(f_table_name) = upper(%1)" )
5420- .arg ( QgsSpatiaLiteProvider::quotedValue ( tableName ) );
5421- ret = sqlite3_exec ( sqlite_handle, sql.toUtf8 ().constData (), nullptr , nullptr , nullptr );
5422- if ( ret != SQLITE_OK )
5423- {
5424- QgsDebugMsg ( " sqlite error: " + QString::fromUtf8 ( sqlite3_errmsg ( sqlite_handle ) ) );
5425- }
5426- #endif
54275374
54285375 // TODO: remove spatial indexes?
54295376 // run VACUUM to free unused space and compact the database
0 commit comments