ERROR database schema_error ai_generated true

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

Also available as: JSON · Markdown
90%Fix Rate
92%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
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.

generic

Workarounds

  1. 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;
  2. 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:

  1. 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.

  2. 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.

Error Chain

Leads to:
Preceded by:
Frequently confused with: