Avoid visiting a type twice in find_composite_type_dependencies()

When recursing, keep track of visited types in a hash table.  This is
currently just an insignificant performance optimization, but it will
come handy in the upcoming patches where we can use the hash table to
do expensive catalog scans only once.  The upcoming patches will be
backpatched which is why this is backpatched too.

Add a test for the case that a type ultimately depends on the same
composite type via two different paths.  That's the case where the
hash table lets us avoid some work.  It isn't very likely to be
broken, but let's have coverage for it for the sake of completeness.

Security: CVE-2026-6460
Backpatch-through: 14

Branch
------
REL_16_STABLE

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

Modified Files
--------------
src/backend/commands/tablecmds.c                | 53 +++++++++++++++++++++----
src/test/regress/expected/alter_column_type.out |  7 ++++
src/test/regress/sql/alter_column_type.sql      |  8 ++++
3 files changed, 61 insertions(+), 7 deletions(-)

Reply via email to