Skip to content

Commit

Permalink
Fix an oversight in format 2: nextlsn
Browse files Browse the repository at this point in the history
Format 2 (1b0cbac) forgot to add
nextlsn. Format 1 includes this information if include-lsn is provided.
This information can be useful for applications that use LSN position as
a restart point.
  • Loading branch information
eulerto committed Jul 26, 2020
1 parent 3511384 commit 8600d48
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions wal2json.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,10 @@ pg_decode_begin_txn_v2(LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(txn->final_lsn)));
appendStringInfo(ctx->out, ",\"lsn\":\"%s\"", lsn_str);
pfree(lsn_str);

lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(txn->end_lsn)));
appendStringInfo(ctx->out, ",\"nextlsn\":\"%s\"", lsn_str);
pfree(lsn_str);
}

appendStringInfoChar(ctx->out, '}');
Expand Down Expand Up @@ -931,6 +935,10 @@ pg_decode_commit_txn_v2(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(commit_lsn)));
appendStringInfo(ctx->out, ",\"lsn\":\"%s\"", lsn_str);
pfree(lsn_str);

lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(txn->end_lsn)));
appendStringInfo(ctx->out, ",\"nextlsn\":\"%s\"", lsn_str);
pfree(lsn_str);
}

appendStringInfoChar(ctx->out, '}');
Expand Down

0 comments on commit 8600d48

Please sign in to comment.