Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
handle potential injector execute error
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma committed Oct 13, 2023
1 parent 7e4d389 commit f749b1d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sqld/src/replication/replica/injector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,12 @@ impl Injector {
// use prepare cached to avoid parsing the same statement over and over again.
let mut stmt =
connection.prepare_cached("INSERT INTO libsql_temp_injection VALUES (42)")?;
stmt.execute(())?;
// force call to xframe
match connection.cache_flush() {

// We execute the statement, and then force a call to xframe if necesacary. If the execute
// succeeds, then xframe wasn't called, in this case, we call cache_flush, and then process
// the error.
// It is unexpected that execute flushes, but it is possible, so we handle that case.
match stmt.execute(()).and_then(|_| connection.cache_flush()) {
Ok(_) => panic!("replication hook was not called"),
Err(e) => {
if let Some(e) = e.sqlite_error() {
Expand Down

0 comments on commit f749b1d

Please sign in to comment.