mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Merge pull request #43989 from elpaso/ogr-sqlite-pragma-defer_foreign_keys-on
OGR/SQLite/GPKG pragma-defer_foreign_keys=ON
This commit is contained in:
commit
6031e7546f
@ -270,6 +270,7 @@ class CORE_EXPORT QgsOgrProviderUtils
|
||||
class QgsOgrDataset
|
||||
{
|
||||
friend class QgsOgrProviderUtils;
|
||||
friend class QgsOgrTransaction;
|
||||
QgsOgrProviderUtils::DatasetIdentification mIdent;
|
||||
QgsOgrProviderUtils::DatasetWithLayers *mDs;
|
||||
|
||||
|
@ -31,6 +31,16 @@ QgsOgrTransaction::QgsOgrTransaction( const QString &connString, QgsOgrDatasetSh
|
||||
|
||||
bool QgsOgrTransaction::beginTransaction( QString &error, int /* statementTimeout */ )
|
||||
{
|
||||
GDALDriverH hDriver = GDALGetDatasetDriver( mSharedDS.get()->mDs->hDS );
|
||||
const QString driverName = GDALGetDriverShortName( hDriver );
|
||||
if ( driverName == QLatin1String( "GPKG" ) || driverName == QLatin1String( "SQLite" ) )
|
||||
{
|
||||
QString fkDeferError;
|
||||
if ( ! executeSql( QStringLiteral( "PRAGMA defer_foreign_keys = ON" ), fkDeferError ) )
|
||||
{
|
||||
QgsDebugMsg( QStringLiteral( "Error setting PRAGMA defer_foreign_keys = ON: %1" ).arg( fkDeferError ) );
|
||||
}
|
||||
}
|
||||
return executeSql( QStringLiteral( "BEGIN" ), error );
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user