1 // Copyright (C) 2018 Yasuhiro Matsumoto <mattn.jp@gmail.com>.
3 // Use of this source code is governed by an MIT-style
4 // license that can be found in the LICENSE file.
6 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
8 #include <sqlite3-binding.h>
10 extern int unlock_notify_wait(sqlite3 *db);
13 _sqlite3_step_blocking(sqlite3_stmt *stmt)
18 db = sqlite3_db_handle(stmt);
20 rv = sqlite3_step(stmt);
21 if (rv != SQLITE_LOCKED) {
24 if (sqlite3_extended_errcode(db) != SQLITE_LOCKED_SHAREDCACHE) {
27 rv = unlock_notify_wait(db);
28 if (rv != SQLITE_OK) {
38 _sqlite3_step_row_blocking(sqlite3_stmt* stmt, long long* rowid, long long* changes)
43 db = sqlite3_db_handle(stmt);
45 rv = sqlite3_step(stmt);
46 if (rv!=SQLITE_LOCKED) {
49 if (sqlite3_extended_errcode(db) != SQLITE_LOCKED_SHAREDCACHE) {
52 rv = unlock_notify_wait(db);
53 if (rv != SQLITE_OK) {
59 *rowid = (long long) sqlite3_last_insert_rowid(db);
60 *changes = (long long) sqlite3_changes(db);
65 _sqlite3_prepare_v2_blocking(sqlite3 *db, const char *zSql, int nBytes, sqlite3_stmt **ppStmt, const char **pzTail)
70 rv = sqlite3_prepare_v2(db, zSql, nBytes, ppStmt, pzTail);
71 if (rv!=SQLITE_LOCKED) {
74 if (sqlite3_extended_errcode(db) != SQLITE_LOCKED_SHAREDCACHE) {
77 rv = unlock_notify_wait(db);
78 if (rv != SQLITE_OK) {