Question on error code selection in conflict detection - Mailing list pgsql-hackers

From Dilip Kumar
Subject Question on error code selection in conflict detection
Date
Msg-id CAFiTN-vJrGgQu0WkY2uRd5bORrUfJKczHUoVMzC4L1oLaCh77Q@mail.gmail.com
Whole thread Raw
Responses Re: Question on error code selection in conflict detection
Re: Question on error code selection in conflict detection
Re: Question on error code selection in conflict detection
List pgsql-hackers
Hi,

I was reviewing the code for conflict reporting and became curious
about the choice of ERRCODE_T_R_SERIALIZATION_FAILURE. This error code
typically signifies a serialization failure within a transaction under
serializable isolation, so its use here for a different type of
conflict seems somewhat out of place. I did notice its use in other
contexts for recovery conflicts in physical replication, which also
struck me as a bit unusual.

Given these observations, I'm wondering if it would be more
appropriate to introduce a new, more specific error code for this
purpose?


static int
errcode_apply_conflict(ConflictType type)
{
switch (type)
{
case CT_INSERT_EXISTS:
case CT_UPDATE_EXISTS:
case CT_MULTIPLE_UNIQUE_CONFLICTS:
return errcode(ERRCODE_UNIQUE_VIOLATION);
case CT_UPDATE_ORIGIN_DIFFERS:
case CT_UPDATE_MISSING:
case CT_DELETE_ORIGIN_DIFFERS:
case CT_DELETE_MISSING:
return errcode(ERRCODE_T_R_SERIALIZATION_FAILURE);
}

Assert(false);
return 0; /* silence compiler warning */
}

-- 
Regards,
Dilip Kumar
Google



pgsql-hackers by date:

Previous
From: Xuneng Zhou
Date:
Subject: Re: Add new wait event to XactLockTableWait
Next
From: Dilip Kumar
Date:
Subject: Re: Add new wait event to XactLockTableWait