PostgreSQL error: function does not exist
ERROR: function round(double precision, integer) does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
The message is precise in a way that is easy to misread: PostgreSQL is not saying "round does not exist" — it is saying no round exists that takes (double precision, integer). The function is usually there, with a different signature, and the HINT about explicit casts is the actual fix more often than not.
What this error means
PostgreSQL resolves functions by name and argument types (overloading), with limited implicit casting. The sample is the canonical case: two-argument round() exists for numeric, not for double precision — so round(x, 2) on a float column fails until you cast. The same mechanism produces operator does not exist: text = integer for comparisons between mismatched types.
Common causes
- Argument type mismatch with an existing function — the round example, or user functions called with the wrong types.
- The extension is not installed:
uuid_generate_v4()needsuuid-ossp(though modern PostgreSQL hasgen_random_uuid()built in — PostgreSQL 13+),ll_to_earth()needsearthdistance, and so on. - Installed in a schema not on
search_path— common when extensions live in a dedicated schema likeextensions. - Different environment: the function or extension exists in prod but not in the test database.
How to diagnose it
\df round -- firme disponibili per nome
\dx -- estensioni installate
-- La funzione esiste da qualche parte fuori search_path?
SELECT n.nspname, p.proname
FROM pg_proc p JOIN pg_namespace n ON n.oid = p.pronamespace
WHERE p.proname = 'uuid_generate_v4';
How to fix it
- Type mismatch → cast the argument:
round(x::numeric, 2). For operators: compare compatible types, casting the constant side where possible so indexes on the column stay usable. - Missing extension →
CREATE EXTENSION "uuid-ossp";(per database, needs appropriate privileges) — or prefer the built-ingen_random_uuid()on PostgreSQL 13+. - Schema → qualify the call (
extensions.uuid_generate_v4()) or add the schema tosearch_pathat the role/database level.
🔍
Same resolution machinery, table edition: relation does not exist.
