| From: | Bruce Momjian <bruce(at)momjian(dot)us> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | Miguel Ferreira <miguelmbferreira(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: Request for Implementation of Custom Error Messages for CHECK Constraints |
| Date: | 2025-05-12 18:19:35 |
| Message-ID: | aCI7t3HmfY9_ZqnS@momjian.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Sat, May 10, 2025 at 07:58:47PM -0400, Tom Lane wrote:
> "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.
Yeah, you could name the constraint
"Custom_error_message_when_the_condition_is_not_met." and then just
convert underscore to spaces and display that to the user.
--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com
Do not let urgent matters crowd out time for investment in the future.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David G. Johnston | 2025-05-12 18:22:21 | Re: Request for Implementation of Custom Error Messages for CHECK Constraints |
| Previous Message | Ants Aasma | 2025-05-12 18:18:05 | Re: Small fixes needed by high-availability tools |