pgsql: Obtain required table lock during cross-table updates, redux. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Obtain required table lock during cross-table updates, redux.
Date
Msg-id E1uXO10-004Y9C-39@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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.universality@gmail.com>
Author: jian he <jian.universality@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: CACJufxGKJtGNRRSXfwMW9SqVOPEMdP17BJ7DsBf=tNsv9pWU9g@mail.gmail.com
Backpatch-through: 13

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3d7a96871c71dc0e6d2614eb4a68179bc7e383db

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(+)


pgsql-committers by date:

Previous
From: Fujii Masao
Date:
Subject: pgsql: Remove leftover dead code from commit_ts.h.
Next
From: Tom Lane
Date:
Subject: pgsql: Add more cross-type comparisons to contrib/btree_gin.