diff options
author | Amit Kapila <akapila@postgresql.org> | 2023-07-25 09:12:29 +0530 |
---|---|---|
committer | Amit Kapila <akapila@postgresql.org> | 2023-07-25 09:12:29 +0530 |
commit | d38ad8e31dee1a69f4f6d4b6bb4e007e3751a93c (patch) | |
tree | ff3b2c1be20a078b2f0e6f20127a4dc08a07b187 /src/backend/replication/logical/proto.c | |
parent | f3bc5192889f6f02aa10ca9f24df4eab1f1493c1 (diff) | |
download | postgresql-d38ad8e31dee1a69f4f6d4b6bb4e007e3751a93c.tar.gz postgresql-d38ad8e31dee1a69f4f6d4b6bb4e007e3751a93c.zip |
Fix the display of UNKNOWN message type in apply worker.
We include the message type while displaying an error context in the
apply worker. Now, while retrieving the message type string if the
message type is unknown we throw an error that will hide the original
error. So, instead, we need to simply return the string indicating an
unknown message type.
Reported-by: Ashutosh Bapat
Author: Euler Taveira, Amit Kapila
Reviewed-by: Ashutosh Bapat
Backpatch-through: 15
Discussion: https://postgr.es/m/CAExHW5suAEDW-mBZt_qu4RVxWZ1vL54-L+ci2zreYWebpzxYsA@mail.gmail.com
Diffstat (limited to 'src/backend/replication/logical/proto.c')
-rw-r--r-- | src/backend/replication/logical/proto.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/backend/replication/logical/proto.c b/src/backend/replication/logical/proto.c index f3087132758..504f94d4a77 100644 --- a/src/backend/replication/logical/proto.c +++ b/src/backend/replication/logical/proto.c @@ -1213,9 +1213,11 @@ logicalrep_read_stream_abort(StringInfo in, /* * Get string representing LogicalRepMsgType. */ -char * +const char * logicalrep_message_type(LogicalRepMsgType action) { + static char err_unknown[20]; + switch (action) { case LOGICAL_REP_MSG_BEGIN: @@ -1258,7 +1260,12 @@ logicalrep_message_type(LogicalRepMsgType action) return "STREAM PREPARE"; } - elog(ERROR, "invalid logical replication message type \"%c\"", action); + /* + * This message provides context in the error raised when applying a + * logical message. So we can't throw an error here. Return an unknown + * indicator value so that the original error is still reported. + */ + snprintf(err_unknown, sizeof(err_unknown), "??? (%d)", action); - return NULL; /* keep compiler quiet */ + return err_unknown; } |