Re: pg18: Virtual generated columns are not (yet) safe when superuser selects from them
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: jian he <jian.universality@gmail.com>
Cc: Feike Steenbergen <feikesteenbergen@gmail.com>,
PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Date: 2025-06-24T09:42:46Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Restrict virtual columns to use built-in functions and types
- 0cd69b3d7ef3 18.0 landed
-
Fix virtual generated column type checking for ALTER TABLE
- 49fe1c83ecf3 18.0 landed
-
Expand virtual generated columns in the planner
- 1e4351af329f 18.0 cited
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.