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: Forbid ALTERing column type by default when other objects depend
Date: Mon, 09 Nov 2026 14:21:59 +0000
Message-ID: <E1xQQFz-000000003fe-3eCG@gemulon.postgresql.org> (raw)

Forbid ALTERing column type by default when other objects depend on it

Previously, we'd allow changing the column type of a table or
composite type (ALTER COLUMN / ATTRIBUTE ... TYPE ...) even if there
are objects depending on the row type.  We only made some checks on
dependencies from relation objects, and assumed that dependencies from
other kinds of object were OK.  This commit flips the logic around to
forbid if there are any dependencies, except for relations and a few
other cases that are known to be OK.

This commit is mostly refactoring, but some cases that were previously
broken, like expressions in views, are now forbidden.  Some of the
dependencies that we continue to allow are known to be broken too --
subsequent commits will tighten them up.

The attributions and discussion links are for the whole wider issue
covered by all the related commits, not just the variants fixed by
this one commit.

Reported-by: Andrew Gierth <andrew@tao11.riddles.org.uk>
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Reported-by: Francesco Verardi <frevadiscor89@gmail.com>
Reported-by: Hcamael <baiyjrh@gmail.com>
Reported-by: Tomer Fichman <tomer@irregular.com>
Reported-by: OpenAI Security Research Team
Reported-by: Peter Geoghegan <pg@bowt.ie>
Reported-by: Mehmet Ince @mdisec <mehmet@mehmetince.net>
Reported-by: Bryan Green <dbryan.green@gmail.com>
Reported-by: Sumedh Pathak <sumedhpathak@microsoft.com>
Reported-by: Nicholas Carlini <npc@anthropic.com>
Reported-by: Sergey Shinderuk <s.shinderuk@postgrespro.ru>
Reported-by: Yuxiao Guo <dllggyx@outlook.com>
Reported-by: Nikhil Sontakke <nikhil@planetscale.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Peter Geoghegan <pg@bowt.ie>
Discussion: https://www.postgresql.org/message-id/CA%2BUBoq0F2ua2fQEAU3-6w0oxOgFc9BgEN4gRcchiUUZ%2BWouVrQ%40mail...
Discussion: https://www.postgresql.org/message-id/CA%2BbCEdDvsVApd%2BAADX%3D5uyj6Q5C3r5aruWNzOFaYqaFqLwE_5g%40ma...
Security: CVE-2026-6460
Backpatch-through: 14

Branch
------
REL_18_STABLE

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

Modified Files
--------------
src/backend/commands/tablecmds.c                | 100 ++++++++++++++++++++++--
src/test/regress/expected/alter_column_type.out |  48 ++++--------
src/test/regress/expected/alter_table.out       |  18 +++++
src/test/regress/sql/alter_column_type.sql      |  28 ++-----
src/test/regress/sql/alter_table.sql            |  18 +++++
5 files changed, 153 insertions(+), 59 deletions(-)



view thread (3+ messages)

Message-ID: <E1xQQFz-000000003fe-3eCG@gemulon.postgresql.org>
Permalink:  ../E1xQQFz-000000003fe-3eCG@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xQQFz-000000003fe-3eCG@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: Forbid ALTERing column type by default when other objects depend
  In-Reply-To: <E1xQQFz-000000003fe-3eCG@gemulon.postgresql.org>
  References: <E1xQQFz-000000003fe-3eCG@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