Lab-verifiedReproduced and fixed on PostgreSQL 17.12 · 2026-11-30 · container image postgres:17
PostgreSQL identifies a function by its name and its input argument types only. Parameter names, OUT parameters and the body are not part of that identity, so CREATE FUNCTION fails with 42723 (duplicate_function) when the name and input types match an existing function.
In the lab this came from re-running a script without OR REPLACE, from renaming a parameter, and from adding OUT parameters to an existing function. regprocedure in pg_proc showed the existing signature each time.
01Re-running CREATE FUNCTION without OR REPLACE
price_with_tax(int) already existed. Running a changed CREATE FUNCTION price_with_tax(p_id int) (now with round()) failed with 42723.
CREATE OR REPLACE FUNCTION with the same signature and return type succeeded, and price_with_tax(1) returned 1100.
Setup
CREATE TABLE products (id int PRIMARY KEY, price numeric);
INSERT INTO products VALUES (1, 1000);
CREATE FUNCTION price_with_tax(p_id int) RETURNS numeric LANGUAGE sql AS $$ SELECT price * 1.1 FROM products WHERE id = p_id $$;CREATE TABLE
INSERT 0 1
CREATE FUNCTIONCREATE FUNCTION price_with_tax(p_id int) RETURNS numeric LANGUAGE sql AS $$ SELECT round(price * 1.1) FROM products WHERE id = p_id $$;ERROR: 42723: function "price_with_tax" already exists with same argument typesSELECT p.oid::regprocedure AS signature, pg_get_function_result(p.oid) AS returns FROM pg_proc p WHERE p.proname = 'price_with_tax'; signature | returns
-------------------------+---------
price_with_tax(integer) | numeric
(1 row)price_with_tax(integer) returning numeric is already there, the same signature as the new one.
CREATE OR REPLACE FUNCTION price_with_tax(p_id int) RETURNS numeric LANGUAGE sql AS $$ SELECT round(price * 1.1) FROM products WHERE id = p_id $$;CREATE FUNCTIONUse CREATE OR REPLACE in deployment scripts so they can run twice. It only works when the return type and parameter names stay the same (otherwise see 42P13).
SELECT price_with_tax(1); price_with_tax
----------------
1100
(1 row)02Only the parameter name changed (p_amt → amount)
calc_tax(p_amt numeric) existed, and CREATE FUNCTION calc_tax(amount numeric) was expected to make a new version. The input type is still numeric, so it failed with 42723.
After DROP FUNCTION calc_tax(numeric) and creating it again, the named call calc_tax(amount => 500) returned 50.0.
Setup
CREATE FUNCTION calc_tax(p_amt numeric) RETURNS numeric LANGUAGE sql AS $$ SELECT p_amt * 0.1 $$;CREATE FUNCTIONCREATE FUNCTION calc_tax(amount numeric) RETURNS numeric LANGUAGE sql AS $$ SELECT amount * 0.1 $$;ERROR: 42723: function "calc_tax" already exists with same argument typesSELECT p.oid::regprocedure AS signature, pg_get_function_arguments(p.oid) AS arguments FROM pg_proc p WHERE p.proname = 'calc_tax'; signature | arguments
-------------------+---------------
calc_tax(numeric) | p_amt numeric
(1 row)The signature is calc_tax(numeric) with argument p_amt numeric: the name is not part of the signature.
DROP FUNCTION calc_tax(numeric);
CREATE FUNCTION calc_tax(amount numeric) RETURNS numeric LANGUAGE sql AS $$ SELECT amount * 0.1 $$;DROP FUNCTION
CREATE FUNCTIONCREATE OR REPLACE cannot rename an input parameter (42P13), so drop and create.
SELECT calc_tax(amount => 500); calc_tax
----------
50.0
(1 row)03Adding OUT parameters to an existing function
get_price(int) returned numeric. A new version get_price(p_id int, OUT price numeric, OUT currency text) was created as a separate function, but OUT parameters do not count in the signature, so it was still get_price(integer) and failed with 42723.
After DROP FUNCTION get_price(int) and creating the new one, SELECT * FROM get_price(1) returned 10.5 and USD.
Setup
CREATE FUNCTION get_price(p_id int) RETURNS numeric LANGUAGE sql AS $$ SELECT 10.5 $$;CREATE FUNCTIONCREATE FUNCTION get_price(p_id int, OUT price numeric, OUT currency text) LANGUAGE sql AS $$ SELECT 10.5, 'USD' $$;ERROR: 42723: function "get_price" already exists with same argument typesSELECT p.oid::regprocedure AS signature, pg_get_function_result(p.oid) AS returns FROM pg_proc p WHERE p.proname = 'get_price'; signature | returns
--------------------+---------
get_price(integer) | numeric
(1 row)The existing get_price(integer) returns numeric; the new definition has the same input type integer.
DROP FUNCTION get_price(int);
CREATE FUNCTION get_price(p_id int, OUT price numeric, OUT currency text) LANGUAGE sql AS $$ SELECT 10.5, 'USD' $$;DROP FUNCTION
CREATE FUNCTIONChanging the result shape also cannot be done with OR REPLACE (42P13), so drop the old one first.
SELECT * FROM get_price(1); price | currency
-------+----------
10.5 | USD
(1 row)FAQ
How do I fix function already exists with same argument types?
If the definition keeps the same return type and parameter names, use CREATE OR REPLACE FUNCTION. Otherwise DROP FUNCTION name(arg types) and create it again.
Can PostgreSQL overload functions by parameter name?
No. Only the input argument types count. calc_tax(p_amt numeric) and calc_tax(amount numeric) are the same function.
Do OUT parameters make a different function signature?
No. get_price(p_id int, OUT price numeric, ...) has the signature get_price(integer), the same as the old one.
How do I see existing functions with the same name?
SELECT p.oid::regprocedure FROM pg_proc p WHERE p.proname = 'calc_tax'; shows each signature, e.g. calc_tax(numeric).
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