@@ -678,9 +678,14 @@ def get_continuation(width, *_):
678678 def show_suggestion_tip ():
679679 return iterations < 2
680680
681+ # Keep track of whether or not the query is mutating. In case
682+ # of a multi-statement query, the overall query is considered
683+ # mutating if any one of the component statements is mutating
684+ mutating = False
685+
681686 def output_res (res , start ):
687+ nonlocal mutating
682688 result_count = 0
683- mutating = False
684689 for title , cur , headers , status in res :
685690 logger .debug ("headers: %r" , headers )
686691 logger .debug ("rows: %r" , cur )
@@ -700,7 +705,14 @@ def output_res(res, start):
700705 else :
701706 max_width = None
702707
703- formatted = self .format_output (title , cur , headers , special .is_expanded_output (), max_width )
708+ formatted = self .format_output (
709+ title ,
710+ cur ,
711+ headers ,
712+ special .is_expanded_output (),
713+ special .is_redirected (),
714+ max_width ,
715+ )
704716
705717 t = time () - start
706718 try :
@@ -710,14 +722,18 @@ def output_res(res, start):
710722 self .output (formatted , status )
711723 except KeyboardInterrupt :
712724 pass
725+ if self .beep_after_seconds > 0 and t >= self .beep_after_seconds :
726+ self .bell ()
727+ if special .is_timing_enabled ():
728+ self .echo ("Time: %0.03fs" % t )
713729 self .echo ("Time: %0.03fs" % t )
714730 except KeyboardInterrupt :
715731 pass
716732
717733 start = time ()
718734 result_count += 1
719735 mutating = mutating or is_mutating (status )
720- return mutating
736+ return
721737
722738 def one_iteration (text = None ):
723739 if text is None :
@@ -793,11 +809,6 @@ def one_iteration(text=None):
793809 else :
794810 destroy = True
795811
796- # Keep track of whether or not the query is mutating. In case
797- # of a multi-statement query, the overall query is considered
798- # mutating if any one of the component statements is mutating
799- mutating = False
800-
801812 try :
802813 logger .debug ("sql: %r" , text )
803814
@@ -813,53 +824,7 @@ def one_iteration(text=None):
813824 self .main_formatter .query = text
814825 self .redirect_formatter .query = text
815826 successful = True
816- result_count = 0
817- for title , cur , headers , status in res :
818- logger .debug ("headers: %r" , headers )
819- logger .debug ("rows: %r" , cur )
820- logger .debug ("status: %r" , status )
821- threshold = 1000
822- if is_select (status ) and cur and cur .rowcount > threshold :
823- self .echo ("The result set has more than {} rows." .format (threshold ), fg = "red" )
824- if not confirm ("Do you want to continue?" ):
825- self .echo ("Aborted!" , err = True , fg = "red" )
826- break
827-
828- if self .auto_vertical_output :
829- max_width = self .prompt_app .output .get_size ().columns
830- else :
831- max_width = None
832-
833- if special .forced_horizontal ():
834- max_width = None
835-
836- formatted = self .format_output (
837- title ,
838- cur ,
839- headers ,
840- special .is_expanded_output (),
841- special .is_redirected (),
842- max_width ,
843- )
844-
845- t = time () - start
846- try :
847- if result_count > 0 :
848- self .echo ("" )
849- try :
850- self .output (formatted , status )
851- except KeyboardInterrupt :
852- pass
853- if self .beep_after_seconds > 0 and t >= self .beep_after_seconds :
854- self .bell ()
855- if special .is_timing_enabled ():
856- self .echo ("Time: %0.03fs" % t )
857- except KeyboardInterrupt :
858- pass
859-
860- start = time ()
861- result_count += 1
862- mutating = mutating or destroy or is_mutating (status )
827+ output_res (res , start )
863828 special .unset_once_if_written (self .post_redirect_command )
864829 special .flush_pipe_once_if_written (self .post_redirect_command )
865830 except EOFError as e :
0 commit comments