Skip to content
Permalink
Browse files

[spatialite] Update layer statistics after adding new columns

Fix #8923
  • Loading branch information
m-kuhn committed Mar 14, 2014
1 parent 80c4961 commit 0d7204cd851af77db342c626a7a07684e3185cca
@@ -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(
@@ -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();

0 comments on commit 0d7204c

Please sign in to comment.
You can’t perform that action at this time.