@@ -309,7 +309,7 @@ impl SimpleQueryHandler for DfSessionService {
309309 . await
310310 {
311311 results. push ( result?) ;
312- break ' stmt;
312+ continue ' stmt;
313313 }
314314 }
315315
@@ -762,4 +762,32 @@ mod tests {
762762 let result = hook. handle_simple_query ( stmt, & ctx, & mut client) . await ;
763763 assert ! ( result. is_none( ) ) ;
764764 }
765+
766+ #[ tokio:: test]
767+ async fn test_multiple_statements_with_hook_continue ( ) {
768+ // Bug #227: when a hook returned a result, the code used `break 'stmt`
769+ // which would exit the entire statement loop, preventing subsequent statements
770+ // from being processed.
771+ let session_context = Arc :: new ( SessionContext :: new ( ) ) ;
772+ let auth_manager = Arc :: new ( AuthManager :: new ( ) ) ;
773+
774+ let hooks: Vec < Arc < dyn QueryHook > > = vec ! [ Arc :: new( TestHook ) ] ;
775+ let service = DfSessionService :: new_with_hooks ( session_context, auth_manager, hooks) ;
776+
777+ let mut client = MockClient :: new ( ) ;
778+
779+ // Mix of queries with hooks and those without
780+ let query = "SELECT magic; SELECT 1; SELECT magic; SELECT 1" ;
781+
782+ let results = <DfSessionService as SimpleQueryHandler >:: do_query ( & service, & mut client, query)
783+ . await
784+ . unwrap ( ) ;
785+
786+ assert_eq ! ( results. len( ) , 4 , "Expected 4 responses" ) ;
787+
788+ assert ! ( matches!( results[ 0 ] , Response :: EmptyQuery ) ) ;
789+ assert ! ( matches!( results[ 1 ] , Response :: Query ( _) ) ) ;
790+ assert ! ( matches!( results[ 2 ] , Response :: EmptyQuery ) ) ;
791+ assert ! ( matches!( results[ 3 ] , Response :: Query ( _) ) ) ;
792+ }
765793}
0 commit comments