Check for Consts in function DEFAULTs and body

A function that uses a composite type as its return or argument type
doesn't prevent altering the composite type.  However, if it's used in
an argument DEFAULT expression, or in the new-style SQL function body,
we must not allow it, because e.g. any Consts in those expressions
would become invalid and we don't have the machinery to rewrite them.
If there's a pg_depend entry on a function, look more closely where
the dependency comes from, and throw an error if it's from those
expressions.

For all reporters and public discussion, see previous commit.

Co-authored-by: Nathan Bossart <[email protected]>
Reviewed-by: Amit Langote <[email protected]>
Reviewed-by: Andres Freund <[email protected]>
Security: CVE-2026-6460
Backpatch-through: 14

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/882eb5025959ddf3570609bb52e7cbaf781227f4
Author: Heikki Linnakangas <[email protected]>

Modified Files
--------------
src/backend/catalog/dependency.c                | 37 +++++++++++++++++++
src/backend/commands/tablecmds.c                | 48 ++++++++++++++++++++++++-
src/include/catalog/dependency.h                |  4 +++
src/test/regress/expected/alter_column_type.out | 16 ++-------
src/test/regress/sql/alter_column_type.sql      |  4 ---
5 files changed, 90 insertions(+), 19 deletions(-)

Reply via email to