pgsql: Forbid ALTERing column type by default when other objects depend

Поиск
Список
Период
Сортировка
Искать

pgsql: Forbid ALTERing column type by default when other objects depend

От:
Noah Misch <noah@leadboat.com>
Дата:
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 
Reported-by: Alexander Lakhin 
Reported-by: Francesco Verardi 
Reported-by: Hcamael 
Reported-by: Tomer Fichman 
Reported-by: OpenAI Security Research Team
Reported-by: Peter Geoghegan 
Reported-by: Mehmet Ince @mdisec 
Reported-by: Bryan Green 
Reported-by: Sumedh Pathak 
Reported-by: Nicholas Carlini 
Reported-by: Sergey Shinderuk 
Reported-by: Yuxiao Guo 
Reported-by: Nikhil Sontakke 
Reviewed-by: Andres Freund 
Reviewed-by: Amit Langote 
Reviewed-by: Álvaro Herrera 
Reviewed-by: Robert Haas 
Reviewed-by: Peter Geoghegan 
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 

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

FAQ