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

From: "Miguel Ferreira" <miguelmbferreira(at)gmail(dot)com>
To: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Request for Implementation of Custom Error Messages for CHECK Constraints
Date: 2025-05-11 10:37:41
Message-ID: 001301dbc260$b9762be0$2c6283a0$@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> Why don't you just choose better names for your constraints?

A word versus a sentence. It's a big difference that greatly improves the
user experience.

> 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.

I understand, I'm looking at it from the point of view of the end user who
is using an application. This application will not need to handle the
message if the database generates a more 'user-friendly' message.

> 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.

The idea is just to be able to define a different message. if I have to use
a trigger to set a different message, then I have to write the same rule
twice, in CHECK and TRIGGER, which is redundant.

Best regards,
Miguel Ferreira

In response to

Browse pgsql-hackers by date

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