diff --git a/GRDB/Core/Database+Statements.swift b/GRDB/Core/Database+Statements.swift index c38870d69..d1d517617 100644 --- a/GRDB/Core/Database+Statements.swift +++ b/GRDB/Core/Database+Statements.swift @@ -588,6 +588,7 @@ extension Database { /// Returns the authorizer that should be used during statement execution /// (this allows preventing the truncate optimization when there exists a /// transaction observer for row deletion). + @usableFromInline func statementWillExecute(_ statement: Statement) throws -> StatementAuthorizer? { // Two things must prevent the statement from executing: aborted // transactions, and database suspension. @@ -603,6 +604,7 @@ extension Database { /// May throw a cancelled commit error, if a transaction observer cancels /// an empty transaction. + @usableFromInline func statementDidExecute(_ statement: Statement) throws { if statement.invalidatesDatabaseSchemaCache { clearSchemaCache() @@ -612,6 +614,7 @@ extension Database { } /// Always throws an error + @usableFromInline func statementDidFail(_ statement: Statement, withResultCode resultCode: Int32) throws -> Never { // Failed statements can not be reused, because sqlite3_reset won't // be able to restore the statement to its initial state: diff --git a/GRDB/Core/DatabaseError.swift b/GRDB/Core/DatabaseError.swift index d492e55dd..9fda1eb42 100644 --- a/GRDB/Core/DatabaseError.swift +++ b/GRDB/Core/DatabaseError.swift @@ -248,6 +248,7 @@ public struct DatabaseError: Error, CustomStringConvertible, CustomNSError { /// /// This initializer is not public because library user is not supposed to /// be exposed to raw result codes. + @usableFromInline init(resultCode: CInt, message: String? = nil, sql: String? = nil, arguments: StatementArguments? = nil) { self.init(resultCode: ResultCode(rawValue: resultCode), message: message, sql: sql, arguments: arguments) } diff --git a/GRDB/Core/RowDecodingError.swift b/GRDB/Core/RowDecodingError.swift index e37ba06e5..cff8dbf4b 100644 --- a/GRDB/Core/RowDecodingError.swift +++ b/GRDB/Core/RowDecodingError.swift @@ -146,6 +146,7 @@ struct RowDecodingContext { } /// Convenience initializer + @usableFromInline init(statement: Statement, index: Int) { self.key = .columnIndex(index) self.row = Row(copiedFromSQLiteStatement: statement.sqliteStatement, statement: statement) diff --git a/GRDB/Core/Statement.swift b/GRDB/Core/Statement.swift index 5946ce420..802293c1c 100644 --- a/GRDB/Core/Statement.swift +++ b/GRDB/Core/Statement.swift @@ -58,6 +58,7 @@ public final class Statement { sqlite3_stmt_readonly(sqliteStatement) != 0 } + @usableFromInline unowned let database: Database /// Cache for index(ofColumn:). Keys are lowercase. diff --git a/GRDB/Core/StatementAuthorizer.swift b/GRDB/Core/StatementAuthorizer.swift index a19b83ce9..44fea582c 100644 --- a/GRDB/Core/StatementAuthorizer.swift +++ b/GRDB/Core/StatementAuthorizer.swift @@ -3,6 +3,7 @@ import Glibc #endif /// A protocol around sqlite3_set_authorizer +@usableFromInline protocol StatementAuthorizer: AnyObject { func authorize( _ actionCode: Int32, diff --git a/GRDB/Core/StatementColumnConvertible.swift b/GRDB/Core/StatementColumnConvertible.swift index e4024dd63..cd95a98af 100644 --- a/GRDB/Core/StatementColumnConvertible.swift +++ b/GRDB/Core/StatementColumnConvertible.swift @@ -129,14 +129,15 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible { /// } /// } public final class FastDatabaseValueCursor : Cursor { - private enum _State { + @usableFromInline + enum _State { case idle, busy, done, failed } - private let _statement: Statement - private let _columnIndex: Int32 - private let _sqliteStatement: SQLiteStatement - private var _state = _State.idle + @usableFromInline let _statement: Statement + @usableFromInline let _columnIndex: Int32 + @usableFromInline let _sqliteStatement: SQLiteStatement + @usableFromInline var _state = _State.idle init(statement: Statement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws { _statement = statement @@ -162,6 +163,7 @@ public final class FastDatabaseValueCursor Value? { switch _state { case .done: @@ -212,14 +214,15 @@ public final class FastDatabaseValueCursor: Cursor where Value: DatabaseValueConvertible & StatementColumnConvertible { - private enum _State { + @usableFromInline + enum _State { case idle, busy, done, failed } - private let _statement: Statement - private let _columnIndex: Int32 - private let _sqliteStatement: SQLiteStatement - private var _state = _State.idle + @usableFromInline let _statement: Statement + @usableFromInline let _columnIndex: Int32 + @usableFromInline let _sqliteStatement: SQLiteStatement + @usableFromInline var _state = _State.idle init(statement: Statement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws { _statement = statement @@ -245,6 +248,7 @@ where Value: DatabaseValueConvertible & StatementColumnConvertible try? _statement.reset() } + @inlinable public func next() throws -> Value?? { switch _state { case .done: