From ec6cfc4fefd9f3a5ee60ed892d98711b1a41faea Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Wed, 4 May 2022 19:40:00 +0100 Subject: [PATCH] Ensure TIMEOUT clauses are processed correctly --- lib/src/dbs/executor.rs | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/src/dbs/executor.rs b/lib/src/dbs/executor.rs index 07824f75..5a93da99 100644 --- a/lib/src/dbs/executor.rs +++ b/lib/src/dbs/executor.rs @@ -233,23 +233,26 @@ impl<'a> Executor<'a> { false => { // Create a transaction 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 - let res = stm.compute(&ctx, &opt, &self.txn(), None).await; - // Catch statement timeout let res = match stm.timeout() { - Some(timeout) => match ctx.is_timedout() { - true => Err(Error::QueryTimeout { - timer: timeout, - }), - false => res, - }, - None => res, + // There is a timeout clause + Some(timeout) => { + // Set statement timeout + let mut ctx = Context::new(&ctx); + ctx.add_timeout(timeout); + let ctx = ctx.freeze(); + // 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 match &res {