Re: pg18: Virtual generated columns are not (yet) safe when superuser selects from them

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Feike Steenbergen <feikesteenbergen(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg18: Virtual generated columns are not (yet) safe when superuser selects from them
Date: 2025-06-24 09:42:46
Message-ID: 07575efa-a62d-4b72-b4ef-3337112449e2@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 23.06.25 18:11, jian he wrote:
> seems we didn't check the ALTER TABLE case.
>
> CREATE TYPE double_int as (a int, b int);
> CREATE TABLE y (a int);
> alter table y add column b double_int GENERATED ALWAYS AS ((a * 2, a *
> 3)) VIRTUAL;
>
> in ATExecAddColumn, we can change it to:
> CheckAttributeType(NameStr(attribute->attname),
> attribute->atttypid, attribute->attcollation,
> list_make1_oid(rel->rd_rel->reltype),
> (attribute->attgenerated ==
> ATTRIBUTE_GENERATED_VIRTUAL ? CHKATYPE_IS_VIRTUAL : 0));

Yes, this is an existing fault separate from this patch. I have pushed
a fix for this along these lines.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Luzanov 2025-06-24 10:02:04 Re: Things I don't like about \du's "Attributes" column
Previous Message Roman Khapov 2025-06-24 09:40:37 Hooks or another better way to track session objects