diff --git a/src/libs/sqlite/sqlitebasestatement.cpp b/src/libs/sqlite/sqlitebasestatement.cpp index 28ebbb8d2ea..1600e6e9776 100644 --- a/src/libs/sqlite/sqlitebasestatement.cpp +++ b/src/libs/sqlite/sqlitebasestatement.cpp @@ -110,12 +110,9 @@ void BaseStatement::waitForUnlockNotify() const unlockNotification.wait(); } -void BaseStatement::reset() const +void BaseStatement::reset() const noexcept { - int resultCode = sqlite3_reset(m_compiledStatement.get()); - - if (resultCode != SQLITE_OK) - checkForResetError(resultCode); + sqlite3_reset(m_compiledStatement.get()); } bool BaseStatement::next() const @@ -448,42 +445,6 @@ void BaseStatement::checkForStepError(int resultCode) const throwUnknowError("SqliteStatement::stepStatement: unknown error has happened"); } -void BaseStatement::checkForResetError(int resultCode) const -{ - switch (resultCode) { - case SQLITE_BUSY_RECOVERY: - case SQLITE_BUSY_SNAPSHOT: - case SQLITE_BUSY_TIMEOUT: - case SQLITE_BUSY: - throwStatementIsBusy("SqliteStatement::stepStatement: database engine was unable to " - "acquire the database locks!"); - case SQLITE_ERROR_MISSING_COLLSEQ: - case SQLITE_ERROR_RETRY: - case SQLITE_ERROR_SNAPSHOT: - case SQLITE_ERROR: - throwStatementHasError("SqliteStatement::stepStatement: run-time error (such as a " - "constraint violation) has occurred!"); - case SQLITE_MISUSE: - throwStatementIsMisused("SqliteStatement::stepStatement: was called inappropriately!"); - case SQLITE_CONSTRAINT_CHECK: - case SQLITE_CONSTRAINT_COMMITHOOK: - case SQLITE_CONSTRAINT_FOREIGNKEY: - case SQLITE_CONSTRAINT_FUNCTION: - case SQLITE_CONSTRAINT_NOTNULL: - case SQLITE_CONSTRAINT_PINNED: - case SQLITE_CONSTRAINT_PRIMARYKEY: - case SQLITE_CONSTRAINT_ROWID: - case SQLITE_CONSTRAINT_TRIGGER: - case SQLITE_CONSTRAINT_UNIQUE: - case SQLITE_CONSTRAINT_VTAB: - case SQLITE_CONSTRAINT: - throwConstraintPreventsModification( - "SqliteStatement::stepStatement: contraint prevent insert or update!"); - } - - throwUnknowError("SqliteStatement::reset: unknown error has happened"); -} - void BaseStatement::checkForPrepareError(int resultCode) const { switch (resultCode) { diff --git a/src/libs/sqlite/sqlitebasestatement.h b/src/libs/sqlite/sqlitebasestatement.h index 2ec0665f568..e8e9026dae3 100644 --- a/src/libs/sqlite/sqlitebasestatement.h +++ b/src/libs/sqlite/sqlitebasestatement.h @@ -68,7 +68,7 @@ public: bool next() const; void step() const; - void reset() const; + void reset() const noexcept; Type fetchType(int column) const; int fetchIntValue(int column) const; @@ -109,7 +109,6 @@ public: sqlite3 *sqliteDatabaseHandle() const; [[noreturn]] void checkForStepError(int resultCode) const; - [[noreturn]] void checkForResetError(int resultCode) const; [[noreturn]] void checkForPrepareError(int resultCode) const; [[noreturn]] void checkForBindingError(int resultCode) const; void setIfIsReadyToFetchValues(int resultCode) const; @@ -174,7 +173,6 @@ public: { Resetter resetter{this}; BaseStatement::next(); - resetter.reset(); } void bindValues() {} @@ -192,7 +190,6 @@ public: Resetter resetter{this}; bindValues(values...); BaseStatement::next(); - resetter.reset(); } template @@ -209,8 +206,6 @@ public: setMaximumResultCount(resultValues.size()); - resetter.reset(); - return resultValues; } @@ -225,8 +220,6 @@ public: if (BaseStatement::next()) resultValue = createValue(); - resetter.reset(); - return resultValue; } @@ -241,8 +234,6 @@ public: if (BaseStatement::next()) resultValue = createOptionalValue>(); - resetter.reset(); - return resultValue; } @@ -271,8 +262,6 @@ public: if (control == CallbackControl::Abort) break; } - - resetter.reset(); } template @@ -284,8 +273,6 @@ public: while (BaseStatement::next()) emplaceBackValues(container); - - resetter.reset(); } template @@ -392,12 +379,6 @@ public: statement.bindValues(queryValues...); } - ~SqliteResultRange() - { - if (!std::uncaught_exceptions()) - resetter.reset(); - } - private: Resetter resetter; }; @@ -418,8 +399,9 @@ public: ~SqliteResultRangeWithTransaction() { + resetter.reset(); + if (!std::uncaught_exceptions()) { - resetter.reset(); m_transaction.commit(); } } @@ -451,25 +433,13 @@ private: void reset() { - try { - if (statement) - statement->reset(); - } catch (...) { - statement = nullptr; - throw; - } + if (statement) + statement->reset(); statement = nullptr; } - ~Resetter() noexcept - { - try { - if (statement) - statement->reset(); - } catch (...) { - } - } + ~Resetter() noexcept { reset(); } StatementImplementation *statement; };