Re: Show expression of virtual columns in error messages

From: solai v <solai(dot)cdac(at)gmail(dot)com>
To: Matheus Alcantara <matheusssilv97(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Peter Eisentraut <peter(at)eisentraut(dot)org>, Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
Subject: Re: Show expression of virtual columns in error messages
Date: 2026-09-17 07:19:56
Message-ID: CAF0whuc1Bk9UBvxGZ3st0pMJ6mLq4qeNxAPAyoU_M8Y+gvaHEw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

On Tue, Sep 15, 2026 at 5:55 PM Matheus Alcantara
<matheusssilv97(at)gmail(dot)com> wrote:
>
> On 10/07/26 18:13, Matheus Alcantara wrote:
> > On Mon Mar 16, 2026 at 12:36 PM -03, Matheus Alcantara wrote:
> >> Attaching v5 with documentation changes included and rebased with master.
> >>
> >
> > Attaching v6 rebased due to changes on a4639d64e21
> >
>
> Attaching v7 rebased with master
>
>
> --

I reviewed and tested the v7 patch and tested the main cases related
to virtual generated columns and found the behavior to be as expected.
I verified that:

1. CHECK constraint errors now show the actual value of the virtual
generated column instead of virtual.
2. NULL/NOT NULL cases correctly show null in the failing row.
3. Overflow from a virtual generated column is now detected during
INSERT itself instead of when the value is read.
4. UPDATE and UPDATE with CHECK constraint work as expected.
5. INSERT ... ON CONFLICT DO UPDATE correctly computes the virtual
column and reports its value in the error.
6. Both MERGE ... WHEN MATCHED THEN UPDATE and MERGE ... WHEN NOT
MATCHED THEN INSERT works correctly.
7. Pass-by-reference values were also tested using a virtual text
generated column.
8. The generated_virtual regression test passed successfully without any issues.

I also went through the relevant executor changes. The virtual
generated columns are computed before constraint checking in the
INSERT/UPDATE paths, and the computed values are available in the
tuple slot for both constraint checking and error reporting. The
corresponding simple replication INSERT/UPDATE paths have also been
updated. One observation I noticed while testing the existing
partition_merge regression test is that the error detail now shows the
computed value instead of virtual. Since the virtual expression uses
tableoid::int, the value is OID-dependent and changes between runs. I
have therefore not modified partition_merge.out with a hard-coded
value. The patch itself does not include a change to that expected
file.
Based on the above testing, the patch behaves as intended in the cases I tested.

Regards
Solai

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Geier 2026-09-17 07:20:34 Re: 回复:[PATCH] Optimize numeric comparisons and aggregations via packed-datum extraction
Previous Message Denis Smirnov 2026-09-17 07:17:17 Re: [PATCH] libpq: Add PQpassfileLookup()