| From: | "Matheus Alcantara" <matheusssilv97(at)gmail(dot)com> |
|---|---|
| To: | "Yugo Nagata" <nagata(at)sraoss(dot)co(dot)jp> |
| Cc: | "Peter Eisentraut" <peter(at)eisentraut(dot)org>, <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Show expression of virtual columns in error messages |
| Date: | 2026-02-05 18:51:54 |
| Message-ID: | DG796MZZAE5S.224STEF6SZTBZ@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed Feb 4, 2026 at 11:45 PM -03, Yugo Nagata wrote:
>> 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).
>
> That would indeed be more useful. One way to achieve this might be to
> modify deparse_context and get_variable() so that a Var is displayed as its
> actual value.
>
I'm not sure if I understand how modifying deparse_context_for() could
help on this.
What I did was to use the expression_tree_mutator API to mutate the
virtual column expression to replace any Var reference with the value
into the TupleTableSlot. Please see the attached v2 version.
> Another possibility would be to include column names in the DETAIL message,
> for example:
>
> ERROR: new row for relation "t" violates check constraint "t_c_check"
> DETAIL: Failing row contains (a, b, c)=(5, 10, a * 2).
>
> Although this would change the existing message format, including column
> names could generally provide users with more information about the error.
>
I think that this could make the error output too verbose when there is
a lot of columns involved on the statement.
--
Matheus Alcantara
EDB: https://www.enterprisedb.com
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-Show-expression-of-virtual-columns-in-error-messa.patch | text/plain | 15.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nathan Bossart | 2026-02-05 19:31:23 | Re: pg_upgrade: transfer pg_largeobject_metadata's files when possible |
| Previous Message | Peter Eisentraut | 2026-02-05 18:42:22 | Re: Pasword expiration warning |