Re: Show expression of virtual columns in error messages - Mailing list pgsql-hackers

From Matheus Alcantara
Subject Re: Show expression of virtual columns in error messages
Date
Msg-id DG6DBW8NDTJC.1U9ELI7JCWOEB@gmail.com
Whole thread Raw
In response to Re: Show expression of virtual columns in error messages  (Peter Eisentraut <peter@eisentraut.org>)
Responses Re: Show expression of virtual columns in error messages
List pgsql-hackers
On Wed Feb 4, 2026 at 11:57 AM -03, Peter Eisentraut wrote:
> On 03.02.26 15:06, Matheus Alcantara wrote:
>> The attached patch changes this behavior to show the virtual column
>> expression instead:
>>
>>    ERROR:  new row for relation "t" violates check constraint "t_c_check"
>>    DETAIL:  Failing row contains (5, 10, a * 2).
>
> Could be useful, but in this context you don't know which column is "a"?

I agree but we at least show more information to the user. The user may
still need to check the table definition to understand the constraint or
to get the column ordering of the table to understand what the value of
"a" is being used to compute the expression.

If the statement declare the columns that the values are referecing this
could be easier to know (e.g INSERT INTO t(a, b) VALUES (5, 10)) but the
user may still need to check the table definition to understand the
constraint.

I see this patch as a way to at least give more information to user
about the error.

Another possibility would be to get the actual values of "a" for example
and show it on the error message, e.g:

    ERROR:  new row for relation "t" violates check constraint "t_c_check"
    DETAIL:  Failing row contains (5, 10, 5 * 2).

--
Matheus Alcantara
EDB: https://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Zsolt Parragi
Date:
Subject: Re: Pasword expiration warning
Next
From: Tom Lane
Date:
Subject: Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects