ERROR: function … does not exist in PostgreSQL rarely means the function is really gone. It means the parser could not find a function that matches all three things at once: the name, a schema in the current search_path, and the argument types of this particular call. Work out which of the three failed and the fix is usually one cast, one schema name or one CREATE EXTENSION.
What PostgreSQL is telling you
The error carries SQLSTATE 42883 (undefined_function). Look closely at the signature in the message: it shows the argument types PostgreSQL saw at the call site, not the ones you meant to pass (parse_func.c).
SELECT round(avg_price, 2) FROM daily_stats;
ERROR: function round(double precision, integer) does not exist
LINE 1: SELECT round(avg_price, 2) FROM daily_stats;
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Here the column is double precision. The only two-argument round takes numeric and integer (math functions), and double precision converts to numeric only on assignment, not implicitly (pg_cast.dat). No candidate matches, so you get "does not exist", even though round obviously exists.
The parser looks up functions much like tables: an unqualified name is searched through the schemas in search_path, and pg_catalog is always searched first unless you list it explicitly (schema search path). Among the functions it finds, it picks one whose argument types match exactly or can be reached through implicit casts (function type resolution). If several match equally well you get a different error, function … is not unique. If the name exists but is a procedure, you get … is a procedure with the hint "To call a procedure, use CALL."
PostgreSQL 19 tells you more. Up to version 18 the usual hint is the generic "You might need to add explicit type casts.", even when types have nothing to do with it. PostgreSQL 19 adds a DETAIL line that says which check failed: there is no function of that name, a function of that name exists but not in the search_path, no version takes this number of arguments, or none takes these argument names or types (parse_func.c, REL_19_STABLE). On 19, read the DETAIL line first.
-- PostgreSQL 19: the DETAIL line says which check failed
ERROR: function uuid_generate_v4() does not exist
DETAIL: A function of that name exists, but it is not in the search_path.
Step 1: find every function with that name
Don't guess. Ask the catalog for every overload in every schema and compare it with what your session searches. current_schemas(true) shows the effective path, including pg_catalog, and leaves out schemas that do not exist or cannot be searched (system information functions).
-- every function with this name, in every schema, with its full signature
SELECT p.oid::regprocedure AS signature,
n.nspname AS schema,
p.prokind AS kind -- f function, p procedure, a aggregate, w window
FROM pg_proc p
JOIN pg_namespace n ON n.oid = p.pronamespace
WHERE p.proname = 'uuid_generate_v4';
-- what this session actually searches, including pg_catalog
SHOW search_path;
SELECT current_schemas(true);
-- the same in psql
\df *.uuid_generate_v4
The result points to one of the causes below. No rows means the function is not in this database at all. Rows in a schema that is missing from current_schemas point to a search path problem. Rows with different argument types mean a type mismatch.
The usual causes and their fixes
- Argument types don't match. The
round(double precision, integer)case above is the classic one. The same happens with a text parameter passed to a function that takesbigint, or avarcharcolumn passed to a function written foruuid. Cast at the call site, or add an overload if many callers need it. Untyped string literals are flexible, but parameters that a driver sends with an explicit type are not, so a query can work in psql and fail from the application. - The function is in a schema outside
search_path. Schemas you have noUSAGEon are silently skipped as well (search_path), so a missing grant also shows up as "does not exist". Schema-qualify the call, or set the path for the role or database instead of per session. The same lookup rules apply to tables, see our guide to "relation does not exist". - The extension is installed in another database.
CREATE EXTENSIONloads objects into the current database only (CREATE EXTENSION).uuid_generate_v4()working inappdbsays nothing aboutappdb_staging. If all you need is a random UUID, the built-ingen_random_uuid()needs no extension (UUID functions). - Case and quoting.
CREATE FUNCTION "GetUser"()keeps the capital letters, but a call toGetUser()without quotes is folded togetuser. Use lower-case names. - Wrong number of arguments or names. A call must supply every parameter that has no default. After a refactor, callers that pass named arguments by the old names stop matching.
- A procedure called with
SELECT, or a function called withCALL. These produce their own error and hint, as described above.
-- round(numeric, integer) is the only two-argument round()
SELECT round(avg_price::numeric, 2) FROM daily_stats;
-- a text parameter passed to an integer function
SELECT get_order($1::bigint);
-- schema-qualify the call (most robust)
SELECT extensions.uuid_generate_v4();
-- or fix the path for a role or a database, not per session
ALTER ROLE app_user SET search_path = app, extensions, public;
ALTER DATABASE appdb SET search_path = app, extensions, public;
-- the extension is missing in THIS database
CREATE SCHEMA IF NOT EXISTS extensions;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA extensions;
Functions that call other functions
A function body written as a string is resolved when it runs, using the caller's search_path. A helper that works from the application can fail for a user, a job or a maintenance command with a different path. You can attach a path to the function with SET search_path, or (since PostgreSQL 14) write SQL functions with a SQL-standard body, which is parsed when the function is created (CREATE FUNCTION). A SET clause has a cost: PostgreSQL does not inline SQL functions that have one (clauses.c), so for small hot functions the standard body is often the better choice.
-- an index expression that calls a helper without a schema
CREATE FUNCTION app.normalize_email(text) RETURNS text
LANGUAGE sql IMMUTABLE
AS 'SELECT lower(trim(app.strip_tags($1)))';
-- pin the path on the function itself
ALTER FUNCTION app.normalize_email(text) SET search_path = app, pg_catalog;
-- or (PostgreSQL 14+) use a SQL-standard body, resolved at creation time
CREATE OR REPLACE FUNCTION app.normalize_email(t text) RETURNS text
LANGUAGE sql IMMUTABLE
RETURN lower(trim(app.strip_tags(t)));
What changes on large systems
On a laptop this error comes from a typo. In production it usually shows up right after something changed the environment around the function.
- Restores run with an empty search path.
pg_dumpsetssearch_pathto an empty string for its own session and records that in the dump (connect.h). Check constraints, defaults, generated columns and index expressions that call your own functions without a schema can then fail while the restore runs, even though they worked for years in production. On a multi-terabyte restore you find out hours in, at index creation. Test restores, and fix function paths before you depend on a dump. - PostgreSQL 17 changed maintenance commands.
ANALYZE,CLUSTER,CREATE INDEX,CREATE MATERIALIZED VIEW,REFRESH MATERIALIZED VIEW,REINDEXandVACUUMnow run functions with a safe search path. Functions used by expression indexes and materialized views must set their own path if they reference other schemas (PostgreSQL 17 release notes). In our experience, after an upgrade from 16 or older this shows up as autovacuum,ANALYZEor a nightly refresh failing on one table. Run the audit below before the upgrade, not after. - Poolers and session settings. With PgBouncer in transaction mode, a
SET search_pathrun by the application is not supported in general (PgBouncer features). Recent PgBouncer versions tracksearch_path, but only with PostgreSQL 18 or newer (track_extra_parameters). Until then you get intermittent "function does not exist" errors that depend on which server connection a transaction lands on. Put the path on the role or database instead (see our PgBouncer guide). - Extensions drift between databases and clusters. On a fleet with per-tenant databases, check
pg_extensionin every database, and create extensions in your migration scripts, not by hand. - Changing a signature creates a new function.
CREATE OR REPLACE FUNCTIONcannot change argument types; trying creates a second, separate overload (CREATE FUNCTION). During a rolling deploy, old and new application versions then call different signatures. In our experience the safe order is: add the new overload, deploy the code, drop the old one later. - Alert on SQLSTATE, not text. Add
%etolog_line_prefixto log the SQLSTATE (log_line_prefix) and alert on a jump in 42883 right after a deploy or migration.
-- functions whose body may depend on the caller's search_path
SELECT p.oid::regprocedure, l.lanname
FROM pg_proc p
JOIN pg_namespace n ON n.oid = p.pronamespace
JOIN pg_language l ON l.oid = p.prolang
WHERE n.nspname NOT IN ('pg_catalog', 'information_schema')
AND p.proconfig IS NULL -- no SET clause
AND p.prosqlbody IS NULL -- not a SQL-standard body
AND l.lanname IN ('sql', 'plpgsql')
ORDER BY 1;
The audit query is broad on purpose. Many listed functions are fine, but each one that calls other user objects without a schema name is a candidate for a SET clause or a standard body.
Key takeaways
- "Function does not exist" means no match on name, schema and argument types together. The function itself usually exists.
- Read the signature in the error: it shows the types PostgreSQL saw. Cast at the call site when they are wrong.
- Use
pg_proc,\df *.nameandcurrent_schemas(true)to see where the function really is. - Extensions are per database. Schemas without
USAGEare skipped silently. - Restores and, since PostgreSQL 17, maintenance commands run with a restricted search path. Pin paths on functions before you upgrade.
- Behind a transaction pooler, set
search_pathon the role or database, not per session.