Skip to content

Count a function as in use only where a call reaches it - #144

Merged
LucaCappelletti94 merged 2 commits into
upstream/function-name-schemafrom
upstream/function-drop-references
Oct 27, 2026
Merged

LucaCappelletti94 merged 2 commits into
upstream/function-name-schemafrom
upstream/function-drop-references

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

DROP FUNCTION refused to drop a function whenever a check constraint, policy or trigger called any function of the same name. Dropping app.f() failed because a policy called public.f(), and dropping f(int, int) failed because a policy called f(id). The cause sat one level down: a check or policy recorded every function carrying the called name, in every schema and with every argument list, and a trigger was matched to its function by bare name.

A call now reaches the functions of that name in the schema it names, or for an unqualified call in pg_catalog and the search path in force where it was written, that accept the number of arguments it passes. Argument types are not inferred, so overloads taking the same number of arguments all stay reachable and their drop stays refused. A trigger is bound when it is created to the function taking no arguments that PostgreSQL would run, and a trigger naming none is refused. The function lists policies and check constraints report narrow accordingly.

This stacks on #143 and retargets to main once #142 and #143 merge.

@LucaCappelletti94 LucaCappelletti94 added the bug Something isn't working label Oct 27, 2026
@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@LucaCappelletti94
LucaCappelletti94 merged commit 634f34e into main Oct 27, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant