Skip to content
Permalink
Browse files
Merge pull request #1406 from m-kuhn/spatialite-fix
[spatialite] Update layer statistics after adding new columns
  • Loading branch information
jef-n committed Jun 11, 2014
2 parents d20c569 + 0d7204c commit 1a85129a9932c28ec9a004c5a11efae7b44f963f
Showing with 14 additions and 0 deletions.
  1. +1 −0 cmake/FindSPATIALITE.cmake
  2. +3 −0 src/providers/spatialite/CMakeLists.txt
  3. +10 −0 src/providers/spatialite/qgsspatialiteprovider.cpp
@@ -69,6 +69,7 @@ IF (SPATIALITE_FOUND)
SET(CMAKE_REQUIRED_LIBRARIES "-F/Library/Frameworks" ${CMAKE_REQUIRED_LIBRARIES})
ENDIF(APPLE)
check_library_exists("${SPATIALITE_LIBRARY}" gaiaDropTable "" SPATIALITE_VERSION_GE_4_0_0)
check_library_exists("${SPATIALITE_LIBRARY}" gaiaStatisticsInvalidate "" SPATIALITE_VERSION_G_4_1_1)

ELSE (SPATIALITE_FOUND)

@@ -33,6 +33,9 @@ QT4_WRAP_CPP(SPATIALITE_MOC_SRCS ${SPATIALITE_MOC_HDRS})
IF(SPATIALITE_VERSION_GE_4_0_0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSPATIALITE_VERSION_GE_4_0_0")
ENDIF(SPATIALITE_VERSION_GE_4_0_0)
IF(SPATIALITE_VERSION_G_4_1_1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSPATIALITE_VERSION_G_4_1_1")
ENDIF(SPATIALITE_VERSION_G_4_1_1)


INCLUDE_DIRECTORIES(
@@ -3827,6 +3827,16 @@ bool QgsSpatiaLiteProvider::addAttributes( const QList<QgsField> &attributes )
// some error occurred
goto abort;
}
#ifdef SPATIALITE_VERSION_GE_4_0_0
sql = QString( "UPDATE geometry_columns_statistics set last_verified = 0 WHERE f_table_name=\"%1\" AND f_geometry_column=\"%2\";" )
.arg( mTableName )
.arg( mGeometryColumn );
ret = sqlite3_exec( sqliteHandle, sql.toUtf8().constData(), NULL, NULL, &errMsg );
update_layer_statistics( sqliteHandle, mTableName.toUtf8().constData(), mGeometryColumn.toUtf8().constData() );
#elif SPATIALITE_VERSION_G_4_1_1
gaiaStatisticsInvalidate( sqliteHandle, tableName.toUtf8().constData(), mGeometryColumn.toUtf8().constData() );
update_layer_statistics( sqliteHandle, mTableName.toUtf8().constData(), mGeometryColumn.toUtf8().constData() );
#endif

// reload columns
loadFields();

0 comments on commit 1a85129

Please sign in to comment.