From f8f629cc137b5c33d322b32ce83747949b21b37a Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 10 Jan 2021 20:14:53 +0100 Subject: QSql/QSqlite: return extended error codes by default SQlite allows to return fine-granulated error codes but this behavior is not enabled by default (due to backwards compatibility concerns). Enable them for the SQLite driver by default but provide an option to disable them when needed. [ChangeLog][QtSql][QSQLITE] The plugin now returns the extended error codes by default. Change-Id: I59cec9aea46eb03f1e7ca02903d769c003a1ae30 Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp') diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp index eb437400b3..bd12b4f3aa 100644 --- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp +++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp @@ -721,6 +721,7 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c bool sharedCache = false; bool openReadOnlyOption = false; bool openUriOption = false; + bool useExtendedResultCodes = true; #if QT_CONFIG(regularexpression) static const QLatin1String regexpConnectOption = QLatin1String("QSQLITE_ENABLE_REGEXP"); bool defineRegexp = false; @@ -744,6 +745,8 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c openUriOption = true; } else if (option == QLatin1String("QSQLITE_ENABLE_SHARED_CACHE")) { sharedCache = true; + } else if (option == QLatin1String("QSQLITE_NO_USE_EXTENDED_RESULT_CODES")) { + useExtendedResultCodes = false; } #if QT_CONFIG(regularexpression) else if (option.startsWith(regexpConnectOption)) { @@ -774,6 +777,7 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c if (res == SQLITE_OK) { sqlite3_busy_timeout(d->access, timeOut); + sqlite3_extended_result_codes(d->access, useExtendedResultCodes); setOpen(true); setOpenError(false); #if QT_CONFIG(regularexpression) -- cgit v1.2.3