Lab-verifiedReproduced and fixed on PostgreSQL 17.12 · 2026-11-29 · container image postgres:17
PostgreSQL allows functions with the same name and different argument types (overloading). When a call matches more than one of them equally well, it stops with 42725 function ... is not unique and the hint Could not choose a best candidate function. You might need to add explicit type casts. A DROP FUNCTION with only the name gives a variant: function name "..." is not unique.
The three runs below cover the common ways to get there. Each time the first step was to list the existing signatures with SELECT oid::regprocedure FROM pg_proc WHERE proname = '...'.
01A new overload with a DEFAULT argument overlaps the old one
order_tax(int) existed, and order_tax(int, rate int DEFAULT 10) was added. SELECT order_tax(1000) matches both, so it failed with function order_tax(integer) is not unique.
pg_proc listed order_tax(integer) and order_tax(integer,integer). After DROP FUNCTION order_tax(int) only the version with the default remained, and order_tax(1000) returned 100.
Setup
CREATE FUNCTION order_tax(amount int) RETURNS int LANGUAGE sql AS $$ SELECT amount / 10 $$;
CREATE FUNCTION order_tax(amount int, rate int DEFAULT 10) RETURNS int LANGUAGE sql AS $$ SELECT amount * rate / 100 $$;CREATE FUNCTION
CREATE FUNCTIONSELECT order_tax(1000);ERROR: 42725: function order_tax(integer) is not unique
LINE 1: SELECT order_tax(1000);
^
HINT: Could not choose a best candidate function. You might need to add explicit type casts.SELECT oid::regprocedure AS signature FROM pg_proc WHERE proname = 'order_tax'; signature
----------------------------
order_tax(integer)
order_tax(integer,integer)
(2 rows)DROP FUNCTION order_tax(int);DROP FUNCTIONTypical after adding a parameter with CREATE OR REPLACE: a different argument list creates a new function instead of replacing the old one.
SELECT order_tax(1000); order_tax
-----------
100
(1 row)02Overloads for bigint and numeric, called with a plain integer
fmt_amount(bigint) and fmt_amount(numeric) both existed. The literal 100 is an integer, which can be converted to either, so SELECT fmt_amount(100) failed with 42725.
Casting the argument chose one: fmt_amount(100::bigint) returned bigint 100 and fmt_amount(100::numeric) returned numeric 100.
Setup
CREATE FUNCTION fmt_amount(v bigint) RETURNS text LANGUAGE sql AS $$ SELECT 'bigint ' || v $$;
CREATE FUNCTION fmt_amount(v numeric) RETURNS text LANGUAGE sql AS $$ SELECT 'numeric ' || v $$;CREATE FUNCTION
CREATE FUNCTIONSELECT fmt_amount(100);ERROR: 42725: function fmt_amount(integer) is not unique
LINE 1: SELECT fmt_amount(100);
^
HINT: Could not choose a best candidate function. You might need to add explicit type casts.SELECT oid::regprocedure AS signature FROM pg_proc WHERE proname = 'fmt_amount'; signature
---------------------
fmt_amount(bigint)
fmt_amount(numeric)
(2 rows)SELECT fmt_amount(100::bigint) AS a, fmt_amount(100::numeric) AS b; a | b
------------+-------------
bigint 100 | numeric 100
(1 row)03DROP FUNCTION with only the name when there are overloads
get_price(int) and get_price(text) both existed. DROP FUNCTION get_price; failed with function name "get_price" is not unique and the hint Specify the argument list to select the function unambiguously.
DROP FUNCTION get_price(text) dropped just that one; pg_proc then listed only get_price(integer).
Setup
CREATE FUNCTION get_price(id int) RETURNS int LANGUAGE sql AS $$ SELECT 100 $$;
CREATE FUNCTION get_price(code text) RETURNS int LANGUAGE sql AS $$ SELECT 200 $$;CREATE FUNCTION
CREATE FUNCTIONDROP FUNCTION get_price;ERROR: 42725: function name "get_price" is not unique
HINT: Specify the argument list to select the function unambiguously.SELECT oid::regprocedure AS signature FROM pg_proc WHERE proname = 'get_price'; signature
--------------------
get_price(integer)
get_price(text)
(2 rows)DROP FUNCTION get_price(text);
SELECT oid::regprocedure AS signature FROM pg_proc WHERE proname = 'get_price';DROP FUNCTION
signature
--------------------
get_price(integer)
(1 row)FAQ
How do I see all versions of a function?
Run SELECT oid::regprocedure FROM pg_proc WHERE proname = 'name';. Each row is one signature with its argument types.
Why do I have two functions after CREATE OR REPLACE?
CREATE OR REPLACE replaces a function only when the argument types are the same. With a different argument list it creates another overload.
How do I fix it without dropping a function?
Cast the arguments so only one version matches, for example fmt_amount(100::numeric).
What does 'function name is not unique' on DROP FUNCTION mean?
There are several functions with that name. Write the argument types: DROP FUNCTION get_price(text);.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary roles created for the test, each owning a schema of the same name; postgres is the superuser. PostgreSQL 17.12