Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6a3631e

Browse files
committed
Escape output of pg_amcheck test
The pg_amcheck test reports a skip message if the layout of the index does not match expectations. That message includes the bytes that were expected and the ones that were found. But the found ones are arbitrary bytes, which can have funny effects on the terminal when they are printed. To avoid that, escape non-word characters before printing. Reviewed-by: Aleksander Alekseev <aleksander@timescale.com> Discussion: https://www.postgresql.org/message-id/flat/3f96f079-64e5-468a-8a19-cb481f0d31e5%40eisentraut.org
1 parent 36578fa commit 6a3631e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/bin/pg_amcheck/t/004_verify_heapam.pl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,11 @@ sub write_tuple
367367
{
368368
close($file); # ignore errors on close; we're exiting anyway
369369
$node->clean_node;
370-
plan skip_all =>
371-
sprintf(
370+
plan skip_all => sprintf(
372371
"Page layout of index %d differs from our expectations: expected (%x, %x, \"%s\"), got (%x, %x, \"%s\")",
373-
$tupidx, 0xDEADF9F9, 0xDEADF9F9, "abcdefg", $a_1, $a_2, $b);
372+
$tupidx, 0xDEADF9F9, 0xDEADF9F9, "abcdefg", $a_1, $a_2,
373+
# escape non-word characters to avoid confusing the terminal
374+
$b =~ s{(\W)}{ sprintf '\x%02x', ord($1) }aegr);
374375
exit;
375376
}
376377

0 commit comments

Comments
 (0)