Ensure TIMEOUT clauses are processed correctly
This commit is contained in:
parent
143da56728
commit
ec6cfc4fef
1 changed files with 18 additions and 15 deletions
|
@ -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
|
|
||||||
if let Some(timeout) = stm.timeout() {
|
|
||||||
let mut new = Context::new(&ctx);
|
|
||||||
new.add_timeout(timeout);
|
|
||||||
ctx = new.freeze();
|
|
||||||
}
|
|
||||||
// Process the statement
|
// Process the statement
|
||||||
let res = stm.compute(&ctx, &opt, &self.txn(), None).await;
|
|
||||||
// Catch statement timeout
|
|
||||||
let res = match stm.timeout() {
|
let res = match stm.timeout() {
|
||||||
Some(timeout) => match ctx.is_timedout() {
|
// There is a timeout clause
|
||||||
true => Err(Error::QueryTimeout {
|
Some(timeout) => {
|
||||||
timer: timeout,
|
// Set statement timeout
|
||||||
}),
|
let mut ctx = Context::new(&ctx);
|
||||||
false => res,
|
ctx.add_timeout(timeout);
|
||||||
},
|
let ctx = ctx.freeze();
|
||||||
None => res,
|
// Process the statement
|
||||||
|
let res = stm.compute(&ctx, &opt, &self.txn(), None).await;
|
||||||
|
// Catch statement timeout
|
||||||
|
match ctx.is_timedout() {
|
||||||
|
true => Err(Error::QueryTimeout {
|
||||||
|
timer: timeout,
|
||||||
|
}),
|
||||||
|
false => res,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// There is no timeout clause
|
||||||
|
None => stm.compute(&ctx, &opt, &self.txn(), None).await,
|
||||||
};
|
};
|
||||||
// Finalise transaction
|
// Finalise transaction
|
||||||
match &res {
|
match &res {
|
||||||
|
|
Loading…
Reference in a new issue