Skip to content

Commit

Permalink
Explain why we call sqlite3_set_authorizer once per database connection
Browse files Browse the repository at this point in the history
  • Loading branch information
groue committed Aug 2, 2019
1 parent c6cb92d commit 870d22f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions GRDB/Core/Database.swift
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,14 @@ extension Database {
}

private func setupAuthorizer() {
// SQLite authorizer is set only once per database connection.
//
// This is because authorizer changes have SQLite invalidate statements,
// with undesired side effects. See:
//
// - DatabaseCursorTests.testIssue583()
// - http://sqlite.1065341.n5.nabble.com/Issue-report-sqlite3-set-authorizer-triggers-error-4-516-SQLITE-ABORT-ROLLBACK-during-statement-itern-td107972.html
// swiftlint:disable:previous line_length
let dbPointer = Unmanaged.passUnretained(self).toOpaque()
sqlite3_set_authorizer(
sqliteConnection,
Expand Down
1 change: 1 addition & 0 deletions Tests/GRDBTests/DatabaseCursorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class DatabaseCursorTests: GRDBTestCase {
}
}

// Regression test for http://github.com/groue/GRDB.swift/issues/583
func testIssue583() throws {
struct User: Codable, TableRecord, FetchableRecord, MutablePersistableRecord {
static let databaseTableName: String = "user"
Expand Down

0 comments on commit 870d22f

Please sign in to comment.