Disallow whole-row variables in GENERATED expressions.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 May 2021 19:12:08 +0000 (15:12 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 May 2021 19:12:08 +0000 (15:12 -0400)
commit4b10074453d182b5fc11a5667bab2ef8532ff3a6
treebe4710e2a55e33fd1502937895acc0ee0a24e904
parent2b0ee126bbf01cbfd657bd53c94f9284ba903ca2
Disallow whole-row variables in GENERATED expressions.

This was previously allowed, but I think that was just an oversight.
It's a clear violation of the rule that a generated column cannot
depend on itself or other generated columns.  Moreover, because the
code was relying on the assumption that no such cross-references
exist, it was pretty easy to crash ALTER TABLE and perhaps other
places.  Even if you managed not to crash, you got quite unstable,
implementation-dependent results.

Per report from Vitaly Ustinov.
Back-patch to v12 where GENERATED came in.

Discussion: https://postgr.es/m/CAM_DEiWR2DPT6U4xb-Ehigozzd3n3G37ZB1+867zbsEVtYoJww@mail.gmail.com
src/backend/catalog/heap.c
src/test/regress/expected/generated.out
src/test/regress/sql/generated.sql