pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Prevent ALTERing a row type that's concurrently used in a column
Date: Mon, 09 Nov 2026 14:22:00 +0000
Message-ID: <E1xQQG0-000000003gK-1F6E@gemulon.postgresql.org> (raw)

Prevent ALTERing a row type that's concurrently used in a column

ALTER TABLE/TYPE checks if the type is being used in a column and
forbids it, because that would require rewriting the data in the
affected table.  But the check missed cases where the type was
concurrently used in a CREATE TABLE or ALTER TABLE ADD COLUMN that
hasn't committed yet.

Commit 2fbb21170e fixed a similar race condition for dropping the
column type altogether, but it wasn't sufficient to fix the problem
with altering the type, because altering a composite type doesn't
currently lock the type.  It does lock the *relation* corresponding to
the type (i.e. pg_type.typrelid), but CREATE TABLE did not hold onto
that lock, even though it acquires it momentarily.  To fix, don't
release the lock.

Reviewed-by: Andres Freund <andres@anarazel.de>
Security: CVE-2026-6460
Backpatch-through: 14

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/26ff7cbd370e568734abe54b65a253058f979c55
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>

Modified Files
--------------
src/backend/catalog/heap.c                       |   7 +-
src/test/isolation/expected/type-ddl-locking.out | 109 ++++++++++++++++
src/test/isolation/isolation_schedule            |   1 +
src/test/isolation/specs/type-ddl-locking.spec   | 157 +++++++++++++++++++++++
4 files changed, 273 insertions(+), 1 deletion(-)



view thread (4+ messages)  latest in thread

Message-ID: <E1xQQG0-000000003gK-1F6E@gemulon.postgresql.org>
Permalink:  ../E1xQQG0-000000003gK-1F6E@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xQQG0-000000003gK-1F6E@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: noah@leadboat.com
  Subject: Re: pgsql: Prevent ALTERing a row type that's concurrently used in a column
  In-Reply-To: <E1xQQG0-000000003gK-1F6E@gemulon.postgresql.org>
  References: <E1xQQG0-000000003gK-1F6E@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