> On 13 Feb 2025, at 18:39, Andres Freund <andres@anarazel.de> wrote:
> The banner being the same between queries made it hard to understand if a
> banner that appeared in the output was from the current query or a past
> query. Therefore I added a counter to it.
+ my $banner = "background_psql: QUERY_SEPARATOR $query_cnt";
+ my $banner_match = qr/(^|\n)$banner\r?\n/;
+ $self->{stdin} .= "$query\n;\n\\echo $banner\n\\warn $banner\n";
+ pump_until(
+ $self->{run}, $self->{timeout},
+ \$self->{stdout}, qr/$banner_match/);
Won't this allow "QUERY_SEPARATOR 11" to match against "QUERY_SEPARATOR 1"?
It's probably only of academic interest but appending an end-of-banner
character like "_" or something after the query counter should fix that.
> For debugging I added a "note" that shows stdout/stderr after executing the
> query, I think it may be worth keeping that, but I'm not sure.
I think it could be worth it, +1 for keeping it until it's beeb proven a
problem somewhere.
> This was a rather painful exercise.
I have no trouble believing that.
--
Daniel Gustafsson