Re: Request for Implementation of Custom Error Messages for CHECK Constraints

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Miguel Ferreira" <miguelmbferreira(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Request for Implementation of Custom Error Messages for CHECK Constraints
Date: 2025-05-10 23:58:47
Message-ID: 739719.1746921527@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Miguel Ferreira" <miguelmbferreira(at)gmail(dot)com> writes:
> I propose extending the syntax of the ALTER TABLE ADD CONSTRAINT
> statement (and potentially CREATE TABLE) to allow for the
> specification of a custom error message for each CHECK constraint.

Why don't you just choose better names for your constraints?

I'd argue that the proposed change might actually be a net loss
for usability, if it entirely obscures the fact that what happened
was a check-constraint violation.

It's also not very clear why we'd stop with check constraints,
if the desire is to get rid of database-produced error messages
in favor of something that somebody likes better.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2025-05-11 00:57:34 Re: Request for Implementation of Custom Error Messages for CHECK Constraints
Previous Message Miguel Ferreira 2025-05-10 21:24:01 Request for Implementation of Custom Error Messages for CHECK Constraints