Re: Question on error code selection in conflict detection

From: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Question on error code selection in conflict detection
Date: 2025-06-13 09:47:53
Message-ID: CAFiTN-uc7be6RzbedFeTydwnf4wQaZ2dqP++kQCHDdFvQDMtBA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jun 11, 2025 at 8:02 PM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
>
> On Wed, Jun 11, 2025 at 7:33 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> >
> > On Tue, Jun 10, 2025 at 2:09 AM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> > > Can we instead try to use other suitable existing error codes?
> >
> > Why?
> >
> > I mean, I'm not 100% against using existing error codes, but I feel
> > like we might be distorting the meanings of the existing error codes.
> > If we used new error codes, then people could test for those and know
> > that they would get exactly these conditions and nothing else.
> >
>
> To enhance the clarity and specificity of our error reporting,
> particularly for logical replication conflicts, I suggest we consider
> defining a dedicated class of error codes, much like we have for FDWs.
> IMHO this would be a more future-proof approach, given the potential
> for many new conflict detection types in the future.

So here is my proposal for adding this new class of error codes and
also the error codes as listed below. I have also changed the same in
the patch. Let me know your thoughts?

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

--
Regards,
Dilip Kumar
Google

Attachment Content-Type Size
v2-0001-Improve-error-codes-for-logical-replication-confl.patch application/octet-stream 2.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2025-06-13 09:49:07 Re: Question on error code selection in conflict detection
Previous Message Laurenz Albe 2025-06-13 08:37:49 Re: pg_upgrade fails with an error "object doesn't exist"