Vitaly Ustinov <vitaly@ustinov.ca> writes: > I would like to report the following: > - a generated column is never updated if you pass the whole record to a > stored procedure (an immutable function);
You could perhaps argue that it'd be okay to pass NULL. The problem with that, though, is that it'd violate the NOT NULL constraint that exists for the generated column. Quite aside from any confusion that ensues at the user level, I'm afraid that that could result in C code crashes --- there are, for example, places in tuple deforming that assume that NOT NULL constraints are truthful.
Knowing why version 12 worked would be helpful in judging whether to live with past decisions, fix poorly made previous decisions, or just move forward with the new behavior in v14 and leave the past alone. I agree that the better design choice would have us forbid this, though that seems problematic in its own right. The function itself is defined correctly and aside from the fact it is in a generated expression it is also called correctly. I suppose the error would be of the form "cannot form a valid whole-row var due to unspecified generated column data"?
FWIW I can definitely see where the OP is coming from with this - the expression at first blush, if one assumes PostgreSQL can handle the nuances, seems like a perfectly reasonable semantic way to express the programmer's desire. Combined with the fact it used to work makes me want to lean toward keeping it working even if it takes come code hackery.