Ensure TIMEOUT clauses are processed correctly

This commit is contained in:
Tobie Morgan Hitchcock 2022-05-04 19:40:00 +01:00
parent 143da56728
commit ec6cfc4fef

View file

@ -233,23 +233,26 @@ impl<'a> Executor<'a> {
false => { false => {
// Create a transaction // Create a transaction
let loc = self.begin().await; let loc = self.begin().await;
// Specify statement timeout // Process the statement
if let Some(timeout) = stm.timeout() { let res = match stm.timeout() {
let mut new = Context::new(&ctx); // There is a timeout clause
new.add_timeout(timeout); Some(timeout) => {
ctx = new.freeze(); // Set statement timeout
} let mut ctx = Context::new(&ctx);
ctx.add_timeout(timeout);
let ctx = ctx.freeze();
// Process the statement // Process the statement
let res = stm.compute(&ctx, &opt, &self.txn(), None).await; let res = stm.compute(&ctx, &opt, &self.txn(), None).await;
// Catch statement timeout // Catch statement timeout
let res = match stm.timeout() { match ctx.is_timedout() {
Some(timeout) => match ctx.is_timedout() {
true => Err(Error::QueryTimeout { true => Err(Error::QueryTimeout {
timer: timeout, timer: timeout,
}), }),
false => res, false => res,
}, }
None => res, }
// There is no timeout clause
None => stm.compute(&ctx, &opt, &self.txn(), None).await,
}; };
// Finalise transaction // Finalise transaction
match &res { match &res {