Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database Lock Prevention #660

Merged
merged 17 commits into from
Dec 3, 2019
4 changes: 2 additions & 2 deletions GRDB/Core/Database+Statements.swift
Original file line number Diff line number Diff line change
@@ -225,7 +225,7 @@ extension Database {
if preventsExclusiveLock.value && statement.createsExclusiveLock {
try? rollback()
throw DatabaseError(
resultCode: .SQLITE_ABORT_EXCLUSIVE,
resultCode: .SQLITE_ABORT,
message: "Can't acquire exclusive lock",
sql: statement.sql,
arguments: statement.arguments)
@@ -308,7 +308,7 @@ extension Database {
if preventsExclusiveLock.value && !statement.isReadonly {
try? rollback()
throw DatabaseError(
resultCode: .SQLITE_ABORT_EXCLUSIVE,
resultCode: .SQLITE_ABORT,
message: "Can't acquire exclusive lock",
sql: statement.sql,
arguments: statement.arguments)
8 changes: 0 additions & 8 deletions GRDB/Core/DatabaseError.swift
Original file line number Diff line number Diff line change
@@ -153,14 +153,6 @@ public struct ResultCode: RawRepresentable, Equatable, CustomStringConvertible {
public static let SQLITE_WARNING_AUTOINDEX = ResultCode(rawValue: (SQLITE_WARNING.rawValue | (1<<8)))
public static let SQLITE_AUTH_USER = ResultCode(rawValue: (SQLITE_AUTH.rawValue | (1<<8)))
public static let SQLITE_OK_LOAD_PERMANENTLY = ResultCode(rawValue: (SQLITE_OK.rawValue | (1<<8)))

// GRDB-specific
/// SQLITE_ABORT_EXCLUSIVE (32772) is thrown when an SQL statement attempts
/// at acquiring an exclusive lock on a database which prevents exclusive
/// lock acquisition.
///
/// See DatabaseWriter.prevents
public static let SQLITE_ABORT_EXCLUSIVE = ResultCode(rawValue: (SQLITE_ABORT.rawValue | (128<<8)))
// swiftlint:enable operator_usage_whitespace line_length
}