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 ------ master Details ------- https://git.postgresql.org/pg/commitdiff/a10f21e6ce549705f194b8fdb28e685403e7579d Modified Files -------------- src/backend/commands/tablecmds.c | 22 ++++++++++++++++++++++ src/test/regress/expected/alter_table.out | 8 ++++++++ src/test/regress/expected/generated_stored.out | 12 ++++++++++++ src/test/regress/expected/generated_virtual.out | 9 +++++++++ src/test/regress/sql/alter_table.sql | 8 ++++++++ src/test/regress/sql/generated_stored.sql | 13 +++++++++++++ src/test/regress/sql/generated_virtual.sql | 13 +++++++++++++ 7 files changed, 85 insertions(+)