PG
PRO
42883ERRORTier 1 — Safe✅ HIGH confidence

function does not exist

Category: Undefined FunctionVersions: All Postgres versions

What this means

The query parser/planner could not find a function (or operator) with the given name and argument type signature in the current search_path. Postgres performs function resolution at parse time using the name and the types of all arguments.

Why it happens

  1. 1Misspelled function name
  2. 2Function exists in a different schema not in search_path
  3. 3Calling a function with incorrect argument types (Postgres overloads by signature)
  4. 4Required extension not installed (e.g., calling uuid_generate_v4() without uuid-ossp)
  5. 5Function was dropped or never created in this database

How to reproduce

A function is called with a wrong name or from a schema not in search_path.

trigger — this will ERROR
SELECT uuid_generate_v4(); -- requires uuid-ossp extension
ERROR: function uuid_generate_v4() does not exist LINE 1: SELECT uuid_generate_v4(); HINT: No function matches the given name and argument types. You might need to add explicit type casts.

Fix 1: Install the required extension

When the function is provided by an extension that is not yet installed.

fix
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
SELECT uuid_generate_v4();

-- Or use the built-in alternative (Postgres 13+):
SELECT gen_random_uuid();

Why this works

Extensions package functions, types, and operators. CREATE EXTENSION copies the extension's SQL objects into the current database's catalog. After installation, the functions are discoverable in the search_path and the planner can resolve them.

Fix 2: Check function signature and add explicit casts

When the function exists but is being called with the wrong argument types.

fix
-- Find matching overloads:
SELECT proname, pg_get_function_arguments(oid)
FROM pg_proc
WHERE proname = 'my_function';

-- Call with explicit cast if needed:
SELECT my_function(42::BIGINT);

Why this works

Postgres function overloading is resolved by matching argument types exactly (after implicit cast consideration). pg_proc stores all function signatures; querying it reveals which overloads exist and what argument types they expect.

What not to do

Add the function's schema to search_path permanently at the database level without review

Why it's wrong: Expanding search_path can cause name conflicts and unintended function shadowing from attacker-controlled schemas.

Version notes

Postgres 13+gen_random_uuid() is built-in; no extension needed for UUID generation.

Sources

📚 Official docs: https://www.postgresql.org/docs/current/errcodes-appendix.html

📚 Feature docs: https://www.postgresql.org/docs/current/typeconv-func.html

🔧 Source ref: src/backend/parser/parse_func.c — ParseFuncOrColumn()

📖 Further reading: Function Type Resolution

Confidence assessment

✅ HIGH confidence

Stable and well-documented. Function resolution rules are consistent across supported versions. Edge case: operator functions (e.g., custom + operators) produce the same error code with a different message when no matching operator is found.

See also

📄 Reference pages

CREATE EXTENSIONFunction Overloadingsearch_path
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →