Skip to content

Commit

Permalink
geopackage : disable WAL explicitely if not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierdalang committed May 26, 2020
1 parent 89e2720 commit 096c803
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/core/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -3991,8 +3991,10 @@ GDALDatasetH QgsOgrProviderUtils::GDALOpenWrapper( const char *pszPath, bool bUp
}

QString filePath( QString::fromUtf8( pszPath ) );

bool bIsGpkg = QFileInfo( filePath ).suffix().compare( QLatin1String( "gpkg" ), Qt::CaseInsensitive ) == 0;
bool bIsLocalGpkg = false;
if ( QFileInfo( filePath ).suffix().compare( QLatin1String( "gpkg" ), Qt::CaseInsensitive ) == 0 &&
if ( bIsGpkg &&
IsLocalFile( filePath ) &&
!CPLGetConfigOption( "OGR_SQLITE_JOURNAL", nullptr ) &&
QgsSettings().value( QStringLiteral( "qgis/walForSqlite3" ), true ).toBool() )
Expand All @@ -4005,6 +4007,12 @@ GDALDatasetH QgsOgrProviderUtils::GDALOpenWrapper( const char *pszPath, bool bUp
CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", "WAL" );
bIsLocalGpkg = true;
}
else if ( bIsGpkg )
{
// If WAL isn't set, we explicitely disable it, as it is persistent and it
// may have been set on a previous connection.
CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", "DELETE" );
}

bool modify_OGR_GPKG_FOREIGN_KEY_CHECK = !CPLGetConfigOption( "OGR_GPKG_FOREIGN_KEY_CHECK", nullptr );
if ( modify_OGR_GPKG_FOREIGN_KEY_CHECK )
Expand Down

0 comments on commit 096c803

Please sign in to comment.