FluentDBFluentDB
PostgreSQL errors

PostgreSQL: function does not exist

ERRORSQLSTATE 42883undefined_function
ERROR: function <name>(<argtypes>) does not exist

No function matches that name and argument types. Often the arguments need a cast to match an existing overload, the function lives in another schema, or it belongs to an extension you have not installed.

What this error means

Postgres resolves functions by name and argument types together. If no function has that exact signature, and no implicit casts make one fit, it raises this error with a HINT about type casts.

A very common case is calling an extension function like uuid_generate_v4() without the extension, or gen_random_uuid() on an older Postgres.

How to fix it

01

The arguments do not match any overload

Cast the arguments to the types the function expects.

sql
SELECT round(value::numeric, 2) FROM t;
02

The function needs an extension

Install it, or use a core equivalent. On Postgres 13+, gen_random_uuid() is built in.

sql
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
03

It is in another schema

Schema-qualify the function, or add its schema to the search_path.

How to avoid it next time

  • Install extensions in migrations, and prefer core functions where they exist.
  • Match argument types to the function signature so overload resolution is unambiguous.
Varies by version

gen_random_uuid() moved into core in Postgres 13. Before that it required the pgcrypto extension, and uuid-ossp was the common alternative.

Frequently asked questions

Why does uuid_generate_v4() fail?

It is provided by the uuid-ossp extension. Install it, or use the built-in gen_random_uuid() on Postgres 13 and later.

The function exists, so why the error?

The argument types do not match its signature. Cast the arguments so exactly one overload fits.

Stop struggling with SQL

Use FluentDB, the AI database client for macOS.