Skip to content

Commit 0885390

Browse files
committed
pg_waldump: Add test case for notice message
Add a test case for the "first record is after" message. Also, this message should really go to stderr, so change to use pg_log_info. Reviewed-by: Tristen Raab <tristen.raab@highgo.ca> Discussion: https://www.postgresql.org/message-id/flat/CAAcByaKM7zyJSDkPWv6_%2BapupY4fXXM3q3SRXas9MMNVPUGcsQ%40mail.gmail.com
1 parent 96063e2 commit 0885390

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

src/bin/pg_waldump/pg_waldump.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,12 +1220,12 @@ main(int argc, char **argv)
12201220
*/
12211221
if (first_record != private.startptr &&
12221222
XLogSegmentOffset(private.startptr, WalSegSz) != 0)
1223-
printf(ngettext("first record is after %X/%X, at %X/%X, skipping over %u byte\n",
1224-
"first record is after %X/%X, at %X/%X, skipping over %u bytes\n",
1225-
(first_record - private.startptr)),
1226-
LSN_FORMAT_ARGS(private.startptr),
1227-
LSN_FORMAT_ARGS(first_record),
1228-
(uint32) (first_record - private.startptr));
1223+
pg_log_info(ngettext("first record is after %X/%X, at %X/%X, skipping over %u byte",
1224+
"first record is after %X/%X, at %X/%X, skipping over %u bytes",
1225+
(first_record - private.startptr)),
1226+
LSN_FORMAT_ARGS(private.startptr),
1227+
LSN_FORMAT_ARGS(first_record),
1228+
(uint32) (first_record - private.startptr));
12291229

12301230
if (config.stats == true && !config.quiet)
12311231
stats.startptr = first_record;

src/bin/pg_waldump/t/001_basic.pl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,25 @@
153153
command_fails_like([ 'pg_waldump', '--quiet', '-p', $node->data_dir, '--start', $start_lsn ], qr/error: error in WAL record at/, 'errors are shown with --quiet');
154154

155155

156+
# Test for: Display a message that we're skipping data if `from`
157+
# wasn't a pointer to the start of a record.
158+
{
159+
# Construct a new LSN that is one byte past the original
160+
# start_lsn.
161+
my ($part1, $part2) = split qr{/}, $start_lsn;
162+
my $lsn2 = hex $part2;
163+
$lsn2++;
164+
my $new_start = sprintf("%s/%X", $part1, $lsn2);
165+
166+
my (@cmd, $stdout, $stderr, $result);
167+
168+
@cmd = ( 'pg_waldump', '--start', $new_start, $node->data_dir . '/pg_wal/' . $start_walfile );
169+
$result = IPC::Run::run \@cmd, '>', \$stdout, '2>', \$stderr;
170+
ok($result, "runs with start segment and start LSN specified");
171+
like($stderr, qr/first record is after/, 'info message printed');
172+
}
173+
174+
156175
# Helper function to test various options. Pass options as arguments.
157176
# Output lines are returned as array.
158177
sub test_pg_waldump

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy