Simplify code building the LR conflict messages
Peter Smith <smithpb2250@gmail.com>
From: Peter Smith <smithpb2250@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-11-28T01:34:14Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Improve errdetail for logical replication conflict messages.
- 48efefa6caac 19 (unreleased) landed
Attachments
- v1-0001-Simplify-the-code-building-the-conflict-messages.patch (application/octet-stream) patch v1-0001
While reviewing another conflict-related thread, I noticed that the
existing conflict messages are currently getting built using
unexpected logic.
e.g
----------
if (tuple_value.len > 0)
{
appendStringInfoString(&tuple_value, "; ");
appendStringInfo(&tuple_value, _("existing local row %s"),
desc);
}
else
{
appendStringInfo(&tuple_value, _("Existing local row %s"),
desc);
}
----------
I couldn't think of a reason why the "; " string needed to be
separated from the rest of the message like that. And when you combine
the strings, the logic easily collapses into a single statement with
less code and greater readability.
There were several code fragments like this. Here is a patch to modify them.
Thoughts?
======
Kind Regards,
Peter Smith.
Fujitsu Australia