@@ -20,7 +20,7 @@ use std::collections::HashSet;
2020use arrow_array:: { RecordBatch , RecordBatchReader } ;
2121use arrow_schema:: Schema ;
2222
23- use crate :: error:: Result ;
23+ use crate :: error:: { Error , Result , Status } ;
2424use crate :: options:: { self , OptionConnection , OptionDatabase , OptionStatement , OptionValue } ;
2525use crate :: PartitionedResult ;
2626
@@ -44,12 +44,13 @@ pub trait Optionable {
4444 fn get_option_double ( & self , key : Self :: Option ) -> Result < f64 > ;
4545}
4646
47- /// A handle to cancel an in-progress operation on a connection .
47+ /// A handle to cancel an in-progress operation.
4848///
4949/// This is a separated handle because otherwise it would be impossible to
50- /// call a `cancel` method on a connection or statement itself.
51- pub trait CancelHandle : Send {
52- /// Cancel the in-progress operation on a connection.
50+ /// safely call a `cancel` method on a database/connection/statement itself
51+ /// due to the borrow checker.
52+ pub trait CancelHandle : Send + Sync {
53+ /// Attempt to cancel the in-progress operation (best-effort).
5354 fn try_cancel ( & self ) -> Result < ( ) > ;
5455}
5556
@@ -58,7 +59,10 @@ pub struct NoOpCancellationHandle;
5859
5960impl CancelHandle for NoOpCancellationHandle {
6061 fn try_cancel ( & self ) -> Result < ( ) > {
61- Ok ( ( ) )
62+ Err ( Error :: with_message_and_status (
63+ "cancellation not implemented" ,
64+ Status :: Unknown ,
65+ ) )
6266 }
6367}
6468
0 commit comments