Skip to content

Commit

Permalink
Remove unnecessary break in pg_logical_replication_slot_advance()
Browse files Browse the repository at this point in the history
pg_logical_replication_slot_advance() included a break condition to stop
when a targeted LSN is reached, when processing a series of WAL records
with XLogReadRecord().  Since 38a9573, it matched with the check of
its main while loop.  This condition saved from an extra CFI check,
actually pointless, so let's remove this condition and simplify the
code.

In passing, fix an incorrect comment.

Author: Bharath Rupireddy
Reviewed-by: Tom Lane, Gurjeet Singh
Discussion: https://postgr.es/m/CALj2ACWfGDLQ2cy7ZKwxnJqbDkO6Yvqqrqxne5ZN4HYm=PRTGg@mail.gmail.com
  • Loading branch information
michaelpq committed Oct 23, 2023
1 parent 40ebc41 commit b6f1cca
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/backend/replication/slotfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ pg_logical_replication_slot_advance(XLogRecPtr moveto)
/* invalidate non-timetravel entries */
InvalidateSystemCaches();

/* Decode at least one record, until we run out of records */
/* Decode records until we reach the requested target */
while (ctx->reader->EndRecPtr < moveto)
{
char *errm = NULL;
Expand All @@ -523,10 +523,6 @@ pg_logical_replication_slot_advance(XLogRecPtr moveto)
if (record)
LogicalDecodingProcessRecord(ctx, ctx->reader);

/* Stop once the requested target has been reached */
if (moveto <= ctx->reader->EndRecPtr)
break;

CHECK_FOR_INTERRUPTS();
}

Expand Down

0 comments on commit b6f1cca

Please sign in to comment.