Skip to content

Commit

Permalink
invalid JSON for non-transaction message in v1 (yugabyte#266)
Browse files Browse the repository at this point in the history
Non-transactional messages contain only one object. It means comma
should not be provided for such JSON objects. If you are sending a
non-transactional message into a transaction, it should guarantee that
comma is only emitted for transactional commands. Hence, the previous
check is weak and it should also check for transactional information.

Fixes yugabyte#266
  • Loading branch information
eulerto committed Feb 16, 2023
1 parent bb7cd50 commit beb9293
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion wal2json.c
Original file line number Diff line number Diff line change
Expand Up @@ -2526,7 +2526,12 @@ pg_decode_message_v1(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,

appendStringInfo(ctx->out, "%s%s", data->ht, data->ht);

if (data->nr_changes > 1)
/*
* Non-transactional message contains only one object. Comma is not
* required. Avoid printing a comma for non-transactional messages that was
* provided in a transaction.
*/
if (transactional && data->nr_changes > 1)
appendStringInfoChar(ctx->out, ',');

appendStringInfo(ctx->out, "{%s%s%s%s\"kind\":%s\"message\",%s", data->nl, data->ht, data->ht, data->ht, data->sp, data->nl);
Expand Down

0 comments on commit beb9293

Please sign in to comment.