Skip to content

Commit

Permalink
[spatialite] Update layer statistics after adding new columns
Browse files Browse the repository at this point in the history
Fix #8923
  • Loading branch information
m-kuhn committed Mar 14, 2014
1 parent 80c4961 commit 0d7204c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmake/FindSPATIALITE.cmake
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions src/providers/spatialite/CMakeLists.txt
Expand Up @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Expand Up @@ -3825,6 +3825,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();
Expand Down

0 comments on commit 0d7204c

Please sign in to comment.