Dear hackers,

Thanks for giving comments!

I intended to avoid constructing messages and it added some complexity. I
understood codes were hard to accept, attached is a simplified version. All info
like key, local tuple, remote tuple, and replica identity are shown after the
colon with the order. I also tried to reduce changes as much as possible.
Additionally, changes in ReportApplyConflict() are moved to 0002.

BTW, I found that in CT_UPDATE_ORIGIN_DIFFERS and CT_DELETE_ORIGIN_DIFFERS cases
assume localts is available because it can happen only when the commit_timestamp
is tracked. I think the assumption is OK, but can we add Assert(localts) for 
them?
If acceptable I can add up more top-up patch.

Rest compares DETAIL part for each conflict reasons with HEAD and patched.

CT_MULTIPLE_UNIQUE_CONFLICTS by INSERT:
HEAD)
Key already exists in unique index "foo_pkey", modified locally in transaction 
801 at 2026-xxx.
Key (a)=(6); existing local row (6, 6, 6); remote row (6, 7, 8).
Key already exists in unique index "foo_b_key", modified locally in transaction 
801 at 2026-xxx.
Key (b)=(7); existing local row (7, 7, 7); remote row (6, 7, 8).
Key already exists in unique index "foo_c_key", modified locally in transaction 
801 at 2026-xxx.
Key (c)=(8); existing local row (8, 8, 8); remote row (6, 7, 8).

Patched)
Could not apply remote change: remote row (6, 7, 8).
Key already exists in unique index "foo_pkey", modified locally in transaction 
801 at 2026-xxx: key (a)=(6), local row (6, 6, 6).
Key already exists in unique index "foo_b_key", modified locally in transaction 
801 at 2026-xxx: key (b)=(7), local row (7, 7, 7).
Key already exists in unique index "foo_c_key", modified locally in transaction 
801 at 2026-xxx: key (c)=(8), local row (8, 8, 8).

CT_MULTIPLE_UNIQUE_CONFLICTS by UPDATE:
HEAD)
Key already exists in unique index "foo_pkey", modified locally in transaction 
801 at 2026-xxx.
Key (a)=(6); existing local row (6, 6, 6); remote row (6, 7, 8); replica 
identity (a)=(5).
Key already exists in unique index "foo_b_key", modified locally in transaction 
801 at 2026-xxx.
Key (b)=(7); existing local row (7, 7, 7); remote row (6, 7, 8); replica 
identity (a)=(5).
Key already exists in unique index "foo_c_key", modified locally in transaction 
801 at 2026-xxx.
Key (c)=(8); existing local row (8, 8, 8); remote row (6, 7, 8); replica 
identity (a)=(5).

Patched)
Could not apply remote change: remote row (6, 7, 8), replica identity (a)=(5).
Key already exists in unique index "foo_pkey", modified locally in transaction 
804 at 2026-xxx: key (a)=(6), local row (6, 6, 6).
Key already exists in unique index "foo_b_key", modified locally in transaction 
804 at 2026-xxx: key (b)=(7), local row (7, 7, 7).
Key already exists in unique index "foo_c_key", modified locally in transaction 
804 at 2026-xxx: key (c)=(8), local row (8, 8, 8).

CT_UPDATE_ORIGIN_DIFFERS:
HEAD)
Updating the row that was modified locally in transaction 802 at 2026-xxx.
Existing local row (5, 5, 5); remote row (6, 7, 8); replica identity (a)=(5).

Patched)
Updating the row that was modified locally in transaction 802 at 2026-xxx: 
local row (5, 5, 5), remote row (6, 7, 8), replica identity (a)=(5).

CT_UPDATE_MISSING:
HEAD)
Could not find the row to be updated.
Remote row (6, 7, 8); replica identity (a)=(6).

Patched)
Could not find the row to be updated: remote row (6, 7, 8), replica identity 
(a)=(6).

CT_DELETE_ORIGIN_DIFFERS:
HEAD)
Deleting the row that was modified locally in transaction 818 at 2026-xxx.
Existing local row (5, 5, 5); replica identity (a)=(5).

Patched)
Deleting the row that was modified locally in transaction 802 at 2026-xxx: 
local row (5, 5, 5), replica identity (a)=(5).

CT_UPDATE_DELETED:
HEAD)
The row to be updated was deleted locally in transaction 801 at 2026-xxx.
Remote row (6, 7, 8); replica identity (a)=(5).

Patched)
Could not find the row to be updated: remote row (6, 7, 8), replica identity 
(a)=(5).
The row to be updated was deleted locally in transaction 801 at 2026-xxx.

CT_DELETE_MISSING:
HEAD)
Could not find the row to be deleted.
Replica identity (a)=(6).

Patched)
Could not find the row to be deleted: replica identity (a)=(6).

Best regards,
Hayato Kuroda
FUJITSU LIMITED

Attachment: v4-0001-Fix-errdetail-for-logical-replication-conflict.patch
Description: v4-0001-Fix-errdetail-for-logical-replication-conflict.patch

Attachment: v4-0002-Fix-primary-error-message-for-conflicts.patch
Description: v4-0002-Fix-primary-error-message-for-conflicts.patch

Reply via email to