Skip to content

Commit

Permalink
Fix pg_rewind debug output to print the source timeline history
Browse files Browse the repository at this point in the history
getTimelineHistory() is called twice, to read the source and the
target timeline history files. However, the loop to print the file
with the --debug option used the wrong variable when dealing with the
source. As a result, the source's history was always printed as empty.

Spotted while debugging bug #18575, but this does not fix that bug,
just the debugging output. Backpatch to all supported versions.

Discussion: https://www.postgresql.org/message-id/[email protected]
(cherry picked from commit b5a5027c9796e2958392f4682928d47b5b0d0e47)
  • Loading branch information
hlinnaka authored and shardgupta committed Dec 6, 2024
1 parent 25e4983 commit 5f99767
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/bin/pg_rewind/pg_rewind.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,7 @@ getTimelineHistory(ControlFileData *controlFile, int *nentries)
pg_free(histfile);
}

/* In debugging mode, print what we read */
if (debug)
{
int i;
Expand All @@ -848,10 +849,7 @@ getTimelineHistory(ControlFileData *controlFile, int *nentries)
else
Assert(false);

/*
* Print the target timeline history.
*/
for (i = 0; i < targetNentries; i++)
for (i = 0; i < *nentries; i++)
{
TimeLineHistoryEntry *entry;

Expand Down

0 comments on commit 5f99767

Please sign in to comment.