Skip to content

Commit d6d7eb7

Browse files
committed
Bypass retry logic for recursive sqlite3_step calls
1 parent 439b8ec commit d6d7eb7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

mvsqlite-preload/shim.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,27 @@ int sqlite3_open16(
9191
abort();
9292
}
9393

94+
static __thread int in_sqlite3_step = 0;
95+
9496
int sqlite3_step(sqlite3_stmt *pStmt) {
9597
int ret;
9698
int autocommit;
97-
sqlite3 *db = sqlite3_db_handle(pStmt);
99+
sqlite3 *db;
100+
101+
if(in_sqlite3_step) {
102+
return real_sqlite3_step(pStmt);
103+
}
104+
105+
in_sqlite3_step = 1;
106+
db = sqlite3_db_handle(pStmt);
98107

99108
while (1) {
100109
autocommit = sqlite3_get_autocommit(db);
101110
ret = real_sqlite3_step(pStmt);
102111
if(ret == SQLITE_BUSY && mvsqlite_enabled && autocommit) {
103112
mvsqlite_autocommit_backoff(db);
104113
} else {
114+
in_sqlite3_step = 0;
105115
return ret;
106116
}
107117
}

0 commit comments

Comments
 (0)