Re: Virtual generated columns - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Virtual generated columns
Date
Msg-id 1662507.1736354338@sss.pgh.pa.us
Whole thread Raw
In response to Re: Virtual generated columns  (Peter Eisentraut <peter@eisentraut.org>)
Responses Re: Virtual generated columns
List pgsql-hackers
Peter Eisentraut <peter@eisentraut.org> writes:
> On 03.12.24 15:15, jian he wrote:
>> SELECT attrelid, attname, attgenerated FROM pg_attribute WHERE
>> attgenerated IN ('v') and (attnotnull or not atthasdef);

> I don't understand what the purpose of testing attnotnull is.  That is 
> independent of attgenerated, I think.

Does it make any sense to set NOT NULL on a generated column (virtual
or otherwise, but especially virtual)?  What is the system supposed
to do if the expression evaluates to null?  That concern generalizes
to any constraint really.  Even if we checked it at row storage time,
there's no real guarantee that the expression is immutable enough
to pass the constraint later.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: ecpg command does not warn COPY ... FROM STDIN;
Next
From: Andrew Dunstan
Date:
Subject: Re: jsonb_strip_nulls with arrays?