@@ -89,7 +89,8 @@ sub new
8989 ' stdin' => ' ' ,
9090 ' stdout' => ' ' ,
9191 ' stderr' => ' ' ,
92- ' query_timer_restart' => undef
92+ ' query_timer_restart' => undef ,
93+ ' query_cnt' => 1,
9394 };
9495 my $run ;
9596
@@ -148,6 +149,8 @@ sub wait_connect
148149 # connection failures are caught here, relieving callers of the need to
149150 # handle those. (Right now, we have no particularly good handling for
150151 # errors anyway, but that might be added later.)
152+ #
153+ # See query() for details about why/how the banner is used.
151154 my $banner = " background_psql: ready" ;
152155 my $banner_match = qr /$banner \r ?\n / ;
153156 $self -> {stdin } .= " \\ echo '$banner '\n\\ warn '$banner '\n " ;
@@ -231,9 +234,11 @@ sub query
231234 my ($self , $query ) = @_ ;
232235 my $ret ;
233236 my $output ;
237+ my $query_cnt = $self -> {query_cnt }++;
238+
234239 local $Test::Builder::Level = $Test::Builder::Level + 1;
235240
236- note " issuing query via background psql: $query " ;
241+ note " issuing query $query_cnt via background psql: $query " ;
237242
238243 $self -> {timeout }-> start() if (defined ($self -> {query_timer_restart }));
239244
@@ -276,11 +281,8 @@ sub query
276281 # would not be one if consuming an empty query result).
277282 $banner_match = qr /\r ?\n ?$banner \r ?\n / ;
278283 $output = $self -> {stdout };
279-
280- # Remove banner again, our caller doesn't care. The first newline is
281- # optional, as there would not be one if consuming an empty query
282- # result.
283- $output =~ s /\n ?$banner\n $// s ;
284+ $output =~ s / $banner_match// ;
285+ $self -> {stderr } =~ s / $banner_match// ;
284286
285287 # clear out output for the next query
286288 $self -> {stdout } = ' ' ;
0 commit comments