Skip to content

Commit

Permalink
Keep a memory of how to trigger #583 error
Browse files Browse the repository at this point in the history
  • Loading branch information
groue committed Aug 2, 2019
1 parent 870d22f commit 55803b2
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Tests/GRDBTests/DatabaseCursorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,46 @@ class DatabaseCursorTests: GRDBTestCase {
User(username: flagged.username)
}
}

// For the record, the lines below show how this test used to fail,
// with raw C SQLite3 apis. The faulty line is the call to
// sqlite3_set_authorizer during the statement iteration.

// if #available(OSX 10.14, *) {
// var connection: SQLiteConnection? = nil
// sqlite3_open_v2(":memory:", &connection, SQLITE_OPEN_READWRITE | SQLITE_OPEN_NOMUTEX, nil)
// sqlite3_extended_result_codes(connection, 1)
//
// sqlite3_exec(connection, """
// CREATE TABLE user (username TEXT NOT NULL);
// CREATE TABLE flagUser (username TEXT NOT NULL);
// INSERT INTO flagUser (username) VALUES ('User1');
// INSERT INTO flagUser (username) VALUES ('User2');
// """, nil, nil, nil)
//
// var statement: SQLiteStatement? = nil
// sqlite3_set_authorizer(connection, { (_, _, _, _, _, _) in SQLITE_OK }, nil)
// sqlite3_prepare_v3(connection, """
// SELECT * FROM flagUser WHERE (SELECT COUNT(*) FROM user WHERE username = flagUser.username) = 0
// """, -1, 0, &statement, nil)
// sqlite3_set_authorizer(connection, nil, nil)
// while true {
// let code = sqlite3_step(statement)
// if code == SQLITE_DONE {
// break
// } else if code == SQLITE_ROW {
// // part of the compilation of another statement, here
// // reduced to the strict minimum that reproduces
// // the error.
// sqlite3_set_authorizer(connection, nil, nil)
// } else {
// print(String(cString: sqlite3_errmsg(connection)))
// XCTFail("Error \(code)")
// break
// }
// }
// sqlite3_finalize(statement)
// sqlite3_close_v2(connection)
// }
}
}

0 comments on commit 55803b2

Please sign in to comment.