index f3087132758f48ae9f686bdaf95a1800e761b9d7..504f94d4a77feb399106d3d3184140d64e8132eb 100644 (file)
/*
* Get string representing LogicalRepMsgType.
*/
-char *
+const char *
logicalrep_message_type(LogicalRepMsgType action)
{
+ static char err_unknown[20];
+
switch (action)
{
case LOGICAL_REP_MSG_BEGIN:
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;
}
index dd353fd1cb0a304ffbaed2a57366a9efb2824eef..cb6659fc619b688629efba6b2577759f771962f2 100644 (file)
default:
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid logical replication message type \"%c\"", action)));
+ errmsg("invalid logical replication message type \"??? (%d)\"", action)));
}
/* Reset the current command */
index 0ea2df50889280e9f97114d80cc88c0356417504..c5be981eae66e272747ef129e6e4dc1fcc38c2a0 100644 (file)
@@ -269,6 +269,6 @@ extern void logicalrep_write_stream_abort(StringInfo out, TransactionId xid,
extern void logicalrep_read_stream_abort(StringInfo in,
LogicalRepStreamAbortData *abort_data,
bool read_abort_info);
-extern char *logicalrep_message_type(LogicalRepMsgType action);
+extern const char *logicalrep_message_type(LogicalRepMsgType action);
#endif /* LOGICAL_PROTO_H */