forked from qt-creator/qt-creator
Sqlite: Change error handling for reset
Error handling in reset() is not needed because it is only repeating the errors of step(). We do already handle them. Reset() is also mostly called in destructors so we can not do much about error there. Reset is only now reset the statement to a clean state again which is what we want. Task-number: QDS-4286 Change-Id: Ifa50859f3d47cc110ef03d7273a01d4419eca9aa Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user