Skip to content

Commit

Permalink
Fix segfault on 32 bits
Browse files Browse the repository at this point in the history
I forgot to pass a Datum and I'm surprised it haven't crashed yet.  This
commit fixes issue #142.

Reported by @df7cb and confirmed by @cpaelzer.
  • Loading branch information
Euler Taveira committed Feb 9, 2020
1 parent fbf9505 commit 695696d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions wal2json.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ pg_decode_begin_txn_v1(LogicalDecodingContext *ctx, ReorderBufferTXN *txn)

if (data->include_lsn)
{
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, txn->end_lsn));
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(txn->end_lsn)));

appendStringInfo(ctx->out, "%s\"nextlsn\":%s\"%s\",%s", data->ht, data->sp, lsn_str, data->nl);

Expand Down Expand Up @@ -706,7 +706,7 @@ pg_decode_begin_txn_v2(LogicalDecodingContext *ctx, ReorderBufferTXN *txn)

if (data->include_lsn)
{
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, txn->final_lsn));
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(txn->final_lsn)));
appendStringInfo(ctx->out, ",\"lsn\":\"%s\"", lsn_str);
pfree(lsn_str);
}
Expand Down Expand Up @@ -780,7 +780,7 @@ pg_decode_commit_txn_v2(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,

if (data->include_lsn)
{
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, commit_lsn));
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(commit_lsn)));
appendStringInfo(ctx->out, ",\"lsn\":\"%s\"", lsn_str);
pfree(lsn_str);
}
Expand Down Expand Up @@ -1681,7 +1681,7 @@ pg_decode_write_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, Relat

if (data->include_lsn)
{
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, change->lsn));
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(change->lsn)));
appendStringInfo(ctx->out, ",\"lsn\":\"%s\"", lsn_str);
pfree(lsn_str);
}
Expand Down Expand Up @@ -2041,7 +2041,7 @@ pg_decode_message_v2(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,

if (data->include_lsn)
{
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, lsn));
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(lsn)));
appendStringInfo(ctx->out, ",\"lsn\":\"%s\"", lsn_str);
pfree(lsn_str);
}
Expand Down Expand Up @@ -2135,7 +2135,7 @@ static void pg_decode_truncate_v1(LogicalDecodingContext *ctx,

if (data->include_lsn)
{
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, change->lsn));
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(change->lsn)));
appendStringInfo(ctx->out, "%s%s%s\"lsn\":%s\"%s\",%s", data->ht, data->ht, data->ht, data->sp, lsn_str, data->nl);
pfree(lsn_str);
}
Expand Down Expand Up @@ -2254,7 +2254,7 @@ static void pg_decode_truncate_v2(LogicalDecodingContext *ctx,

if (data->include_lsn)
{
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, change->lsn));
char *lsn_str = DatumGetCString(DirectFunctionCall1(pg_lsn_out, UInt64GetDatum(change->lsn)));
appendStringInfo(ctx->out, ",\"lsn\":\"%s\"", lsn_str);
pfree(lsn_str);
}
Expand Down

0 comments on commit 695696d

Please sign in to comment.