Search Postgresql Archives

Re: Is it correct to raise an exception in a domain check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 10, 2025 at 4:53 PM Logan Grosz <logan.grosz@xxxxxxxxx> wrote:
Hi,

I have a `DOMAIN` on `JSONB`. I need to verify the shape of the JSON, so I have a check _expression_ written in PL/pgSQL. The docs say

> Each constraint must be an _expression_ producing a Boolean result

Would it be correct to raise an exception to indicate a failed check? I perform type-casts (that throw already) and other checks that would benefit from attaching a description to the client error.

Since PG will throw an error when any CHECK constraint fails, are you hoping to provide more details by throwing your own exception?

--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux