Peter Eisentraut <pe...@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