Obtain required table lock during cross-table updates, redux. Commits 8319e5cb5 et al missed the fact that ATPostAlterTypeCleanup contains three calls to ATPostAlterTypeParse, and the other two also need protection against passing a relid that we don't yet have lock on. Add similar logic to those code paths, and add some test cases demonstrating the need for it.
In v18 and master, the test cases demonstrate that there's a behavioral discrepancy between stored generated columns and virtual generated columns: we disallow changing the expression of a stored column if it's used in any composite-type columns, but not that of a virtual column. Since the expression isn't actually relevant to either sort of composite-type usage, this prohibition seems unnecessary; but changing it is a matter for separate discussion. For now we are just documenting the existing behavior. Reported-by: jian he <jian.universal...@gmail.com> Author: jian he <jian.universal...@gmail.com> Reviewed-by: Tom Lane <t...@sss.pgh.pa.us> Discussion: CACJufxGKJtGNRRSXfwMW9SqVOPEMdP17BJ7DsBf=tnsv9pw...@mail.gmail.com Backpatch-through: 13 Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/e902f818191fb7adce9d3d14150f56e528662fa9 Modified Files -------------- src/backend/commands/tablecmds.c | 22 ++++++++++++++++++++++ src/test/regress/expected/alter_table.out | 8 ++++++++ src/test/regress/sql/alter_table.sql | 8 ++++++++ 3 files changed, 38 insertions(+)