Re: Proposal: Include CHECK constraint expression in violation error DETAIL

From: Koshino Taiki <koshino(at)sraoss(dot)co(dot)jp>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Yash Jadhav <yash(dot)jadhav8008(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Proposal: Include CHECK constraint expression in violation error DETAIL
Date: 2026-12-01 04:59:59
Message-ID: TY7P286MB974944241EED18ED7BF57FD3F3944E2@TY7P286MB974944.JPNP286.PROD.OUTLOOK.COM
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> ERROR: new row for relation "staff_sales" violates check constraint
"staff_age_check"
> DETAIL: Failing row contains (1, 15). Check constraint expression: (age >= 18).
>
> DETAIL mention 2 different, seemingly unrelated things, which seems uncommon.
> Just wondering, have you considered adding it to errhint.
>
> ERROR: new row for relation "staff_sales" violates check constraint
"staff_age_check"
> DETAIL: Failing row contains (1, 15).
> HINT: The row must satisfy the check constraint expression (age >= 18).

HiJian,

Thank you both for your reviews and helpful suggestions.

I agree that showing the CHECK expression as a HINT is more
user-friendly. I therefore moved the table CHECK expression to HINT,
while keeping the failing row in DETAIL.

I also revised the domain constraint message to use similar wording.

DETAIL: The value must satisfy the check constraint expression ...

The corresponding expected test outputs have been updated.

The updated v8 patch is attached.

Regards,

Taiki Koshino<koshino(at)sraoss(dot)co(dot)jp>
SRA OSS K.K.
TEL: 03-5979-2701 FAX: 03-5979-2702
URL: https://www.sraoss.co.jp/

________________________________
差出人: jian he <jian(dot)universality(at)gmail(dot)com>
送信日時: 2026年11月29日 10:10
宛先: Koshino Taiki <koshino(at)sraoss(dot)co(dot)jp>
CC: Yash Jadhav <yash(dot)jadhav8008(at)gmail(dot)com>; PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
件名: Re: Proposal: Include CHECK constraint expression in violation error DETAIL

On Thu, Nov 26, 2026 at 5:36 PM Koshino Taiki <koshino(at)sraoss(dot)co(dot)jp> wrote:
>
> I have removed the redundant check_desc checks from both places and
> attached the updated patch.
>
Hi.

ERROR: new row for relation "staff_sales" violates check constraint
"staff_age_check"
DETAIL: Failing row contains (1, 15). Check constraint expression: (age >= 18).

DETAIL mention 2 different, seemingly unrelated things, which seems uncommon.
Just wondering, have you considered adding it to errhint.

ERROR: new row for relation "staff_sales" violates check constraint
"staff_age_check"
DETAIL: Failing row contains (1, 15).
HINT: The row must satisfy the check constraint expression (age >= 18).

--
jian
https://www.enterprisedb.com/

Attachment Content-Type Size
v8-0001-Improve-tab-completion-for-CREATE-DOMAIN-without-.patch application/octet-stream 107.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Koshino Taiki 2026-12-01 05:09:45 Re: [PATCH] Improve tab completion for CREATE DOMAIN without AS
Previous Message Kirill Reshke 2026-12-01 04:44:29 Re: NOT-IN to ANTI-JOIN conversation changes query result