pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Obtain required table lock during cross-table updates, redux.
Date: Thu, 03 Jul 2025 17:46:31 +0000
Message-ID: <E1uXO11-004Y9M-0A@gemulon.postgresql.org> (raw)

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_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f9ba071cc5bdd2a98c361b5a75e995ffaa0ec787

Modified Files
--------------
src/backend/commands/tablecmds.c          | 8 ++++++++
src/test/regress/expected/alter_table.out | 4 ++++
src/test/regress/sql/alter_table.sql      | 4 ++++
3 files changed, 16 insertions(+)



view thread (13+ messages)  latest in thread

Message-ID: <E1uXO11-004Y9M-0A@gemulon.postgresql.org>
Permalink:  ../E1uXO11-004Y9M-0A@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1uXO11-004Y9M-0A@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Obtain required table lock during cross-table updates, redux.
  In-Reply-To: <E1uXO11-004Y9M-0A@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox