Re: Disallow whole-row index references with virtual generated columns?

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Cc: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: Disallow whole-row index references with virtual generated columns?
Date: 2026-05-08 19:30:31
Message-ID: af45JCwPlRLU6D1D@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2026-May-08, Matthias van de Meent wrote:

> On Fri, 8 May 2026 at 16:12, Álvaro Herrera <alvherre(at)kurilemu(dot)de> wrote:

> > > This is what I tried on master:
> > >
> > > CREATE TABLE t (a int, b int GENERATED ALWAYS AS (a * 2) VIRTUAL);
> > > CREATE UNIQUE INDEX t_a_wholerow_pred_idx ON t (a) WHERE t IS NOT NULL;
> > > INSERT INTO t(a) VALUES (1);
> > > INSERT INTO t(a) VALUES (1); -- accepted, two rows with a = 1
> >
> > Hmm, but this also works just fine when the column b is a normal column,
> > so I don't see why you would want to restrict this specifically for
> > virtual generated columns.
>
> Are you sure it works fine?

I only meant that the sequence that Ayush was saying should fail with
virtual columns and actually fails to fail, also fails to fail with
regular columns. Therefore this is not a virtual column-specific
problem, but something more general that perhaps we have not studied
enough.

TBH I'm not really sure what's the usefulness of indexes over whole-row
types. I imagine the use cases for them are rather infrequent, if not
outright non-existent.

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Cary Huang 2026-05-08 21:36:10 Re: Add ssl_(supported|shared)_groups to sslinfo
Previous Message Mohamed ALi 2026-05-08 19:28:03 [PATCH] Improving Visibility of Temporary Table Usage