From a7789a7db4c9d21c6739c533029db38eac442342 Mon Sep 17 00:00:00 2001 From: Dilip Kumar Date: Fri, 13 Jun 2025 08:43:50 +0000 Subject: [PATCH v2] Improve error codes for logical replication conflict logging This commit updates error codes used in logical replication conflict reporting to be more relevant, enhancing clarity for conflict logging. --- src/backend/replication/logical/conflict.c | 9 +++++---- src/backend/utils/errcodes.txt | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/backend/replication/logical/conflict.c b/src/backend/replication/logical/conflict.c index 97c4e26b586..973dcec8427 100644 --- a/src/backend/replication/logical/conflict.c +++ b/src/backend/replication/logical/conflict.c @@ -172,12 +172,13 @@ errcode_apply_conflict(ConflictType type) case CT_INSERT_EXISTS: case CT_UPDATE_EXISTS: case CT_MULTIPLE_UNIQUE_CONFLICTS: - return errcode(ERRCODE_UNIQUE_VIOLATION); - case CT_UPDATE_ORIGIN_DIFFERS: + return errcode(ERRCODE_L_R_APPLY_CONFLICT_UNIQUE_KEY_CONFLICT); case CT_UPDATE_MISSING: - case CT_DELETE_ORIGIN_DIFFERS: case CT_DELETE_MISSING: - return errcode(ERRCODE_T_R_SERIALIZATION_FAILURE); + return errcode(ERRCODE_L_R_APPLY_CONFLICT_TARGET_ROW_MISSING); + case CT_UPDATE_ORIGIN_DIFFERS: + case CT_DELETE_ORIGIN_DIFFERS: + return errcode(ERRCODE_L_R_APPLY_CONFLICT_ORIGIN_DIFFER); } Assert(false); diff --git a/src/backend/utils/errcodes.txt b/src/backend/utils/errcodes.txt index c96aa7c49ef..b3e84e8036e 100644 --- a/src/backend/utils/errcodes.txt +++ b/src/backend/utils/errcodes.txt @@ -493,6 +493,13 @@ P0002 E ERRCODE_NO_DATA_FOUND no_ P0003 E ERRCODE_TOO_MANY_ROWS too_many_rows P0004 E ERRCODE_ASSERT_FAILURE assert_failure +Section: Class LC - Logical replication conflict logging Error + +# (PostgreSQL-specific error class) +LC001 E ERRCODE_L_R_APPLY_CONFLICT_UNIQUE_KEY_CONFLICT unique_key_conflict +LC002 E ERRCODE_L_R_APPLY_CONFLICT_TARGET_ROW_MISSING target_row_missing +LC003 E ERRCODE_L_R_APPLY_CONFLICT_ORIGIN_DIFFER target_row_origin_differ + Section: Class XX - Internal Error # this is for "can't-happen" conditions and software bugs (PostgreSQL-specific error class) -- 2.50.0.rc1.591.g9c95f17f64-goog