FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Never output a leading comma before non-transactional messages by gclinch · Pull Request #101 · eulerto/wal2json · GitHub

Repository navigation

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .out  (1) .sql  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
36 changes: 35 additions & 1 deletion expected/message.out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ SELECT 'msg10' FROM pg_logical_emit_message(true, 'wal2json', 'this is message #
msg10
(1 row)

COMMIT;
SELECT 'msg11' FROM pg_logical_emit_message(false, 'wal2json', 'this message is outside of a transaction');
?column?
----------
msg11
(1 row)

BEGIN;
SELECT 'msg12' FROM pg_logical_emit_message(true, 'wal2json', 'this message will be printed last');
?column?
----------
msg12
(1 row)

COMMIT;
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'pretty-print', '1');
data
Expand Down Expand Up @@ -160,7 +174,27 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'pre
} +
] +
}
(8 rows)
{ +
"change": [ +
{ +
"kind": "message", +
"transactional": false, +
"prefix": "wal2json", +
"content": "this message is outside of a transaction" +
} +
] +
}
{ +
"change": [ +
{ +
"kind": "message", +
"transactional": true, +
"prefix": "wal2json", +
"content": "this message will be printed last" +
} +
] +
}
(10 rows)

SELECT 'stop' FROM pg_drop_replication_slot('regression_slot');
?column?
Expand Down
6 changes: 6 additions & 0 deletions sql/message.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ SELECT 'msg9' FROM pg_logical_emit_message(false, 'wal2json', 'this message will
SELECT 'msg10' FROM pg_logical_emit_message(true, 'wal2json', 'this is message #2');
COMMIT;

SELECT 'msg11' FROM pg_logical_emit_message(false, 'wal2json', 'this message is outside of a transaction');

BEGIN;
SELECT 'msg12' FROM pg_logical_emit_message(true, 'wal2json', 'this message will be printed last');
COMMIT;

SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'pretty-print', '1');

SELECT 'stop' FROM pg_drop_replication_slot('regression_slot');
2 changes: 1 addition & 1 deletion wal2json.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ pg_decode_message(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,

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

if (data->nr_changes > 1)
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

Back | FazBrowse Home | New Git URL