ERROR: function my_function(integer, text) does not exist HINT: No function matches the given name and argument types.
ID: database/pg-function-does-not-exist
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 16 | active | — | — | — |
Root Cause
PostgreSQL cannot find a function with the given name and argument types. This usually means: the function was not created in the current database/schema, the argument types do not exactly match (PostgreSQL does strict type matching), or the search_path does not include the schema where the function exists. Also common when an extension providing the function was not installed.
genericWorkarounds
-
90% success Verify the function exists and check the search_path
Check if the function exists: SELECT proname, proargtypes FROM pg_proc WHERE proname = 'my_function'; Check search_path: SHOW search_path; If the function is in a non-default schema, either qualify the call (schema.function()) or add the schema to search_path: SET search_path TO public, my_schema;
-
88% success Ensure argument types match exactly, using explicit casts where needed
PostgreSQL uses exact type matching for function resolution. If the function expects integer but you pass bigint, it fails. Use explicit casts: my_function(arg1::integer, arg2::text). Check the function definition: \df my_function in psql to see expected argument types.
Dead Ends
Common approaches that don't work:
-
Casting all arguments to text to bypass type matching
70% fail
Casting to text may call a different overloaded function or fail entirely. PostgreSQL's function resolution depends on exact type matching. Casting loses type safety and can cause incorrect results or runtime errors inside the function.
-
Creating the function in the public schema assuming all databases share it
80% fail
PostgreSQL functions are per-database, not cluster-wide. Creating a function in database A does not make it available in database B. Each database that needs the function must have it created separately.