@@ -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,33 @@ 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 =
783+ <DfSessionService as SimpleQueryHandler >:: do_query ( & service, & mut client, query)
784+ . await
785+ . unwrap ( ) ;
786+
787+ assert_eq ! ( results. len( ) , 4 , "Expected 4 responses" ) ;
788+
789+ assert ! ( matches!( results[ 0 ] , Response :: EmptyQuery ) ) ;
790+ assert ! ( matches!( results[ 1 ] , Response :: Query ( _) ) ) ;
791+ assert ! ( matches!( results[ 2 ] , Response :: EmptyQuery ) ) ;
792+ assert ! ( matches!( results[ 3 ] , Response :: Query ( _) ) ) ;
793+ }
765794}
0 commit comments