| From: | Noah Misch <noah(at)leadboat(dot)com> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Forbid ALTERing column type by default when other objects depend |
| Date: | 2026-11-09 14:21:54 |
| Message-ID: | E1xQQFu-000000003Um-3Tlq@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(at)tao11(dot)riddles(dot)org(dot)uk>
Reported-by: Alexander Lakhin <exclusion(at)gmail(dot)com>
Reported-by: Francesco Verardi <frevadiscor89(at)gmail(dot)com>
Reported-by: Hcamael <baiyjrh(at)gmail(dot)com>
Reported-by: Tomer Fichman <tomer(at)irregular(dot)com>
Reported-by: OpenAI Security Research Team
Reported-by: Peter Geoghegan <pg(at)bowt(dot)ie>
Reported-by: Mehmet Ince @mdisec <mehmet(at)mehmetince(dot)net>
Reported-by: Bryan Green <dbryan(dot)green(at)gmail(dot)com>
Reported-by: Sumedh Pathak <sumedhpathak(at)microsoft(dot)com>
Reported-by: Nicholas Carlini <npc(at)anthropic(dot)com>
Reported-by: Sergey Shinderuk <s(dot)shinderuk(at)postgrespro(dot)ru>
Reported-by: Yuxiao Guo <dllggyx(at)outlook(dot)com>
Reported-by: Nikhil Sontakke <nikhil(at)planetscale(dot)com>
Reviewed-by: Andres Freund <andres(at)anarazel(dot)de>
Reviewed-by: Amit Langote <amitlangote09(at)gmail(dot)com>
Reviewed-by: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Reviewed-by: Robert Haas <robertmhaas(at)gmail(dot)com>
Reviewed-by: Peter Geoghegan <pg(at)bowt(dot)ie>
Discussion: https://www.postgresql.org/message-id/CA%2BUBoq0F2ua2fQEAU3-6w0oxOgFc9BgEN4gRcchiUUZ%2BWouVrQ%40mail.gmail.com
Discussion: https://www.postgresql.org/message-id/CA%2BbCEdDvsVApd%2BAADX%3D5uyj6Q5C3r5aruWNzOFaYqaFqLwE_5g%40mail.gmail.com
Security: CVE-2026-6460
Backpatch-through: 14
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/15cf82750d19fe6798278d6e85843d3addeded0d
Author: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Noah Misch | 2026-11-09 14:21:55 | pgsql: Forbid changing type if the rowtype is used in a foreign table |
| Previous Message | Noah Misch | 2026-11-09 14:21:53 | pgsql: Check EXECUTE privilege on type-to-json cast functions. |