Incident brief
Duplicate function
CREATE FUNCTION fails when a function with the same name and argument types already exists; CREATE OR REPLACE updates it instead of colliding.
What lands in your log
ERROR: function "add_one" already exists with same argument types
In 10 seconds
- What triggers it
- CREATE FUNCTION with a name and argument-type list that already exists.
- Fix
- Use CREATE OR REPLACE FUNCTION to update the existing definition.
- Proof
- Reproduced on PostgreSQL 18.4 → A CREATE FUNCTION reproduces SQLSTATE 42723 against the existing same-signature function.
Fix
What to do right now
Application-level steps for this error.
- Use CREATE OR REPLACE FUNCTION to update the existing definition.
- Or change the argument types to define a genuinely different overload.
-- Update in place with CREATE OR REPLACE FUNCTION.
CREATE OR REPLACE FUNCTION add_one(int) RETURNS int LANGUAGE sql AS 'SELECT $1 + 1';For this error
See this error live on the server
Run these against the affected instance to confirm the diagnosis before you act.
Function identity is name plus input argument types. Inspect overloads before choosing CREATE OR REPLACE or DROP.
Existing overloads
Replace the function name from the error.
SELECT n.nspname AS schema_name, p.proname,
pg_get_function_identity_arguments(p.oid) AS identity_arguments,
pg_get_function_result(p.oid) AS result_type
FROM pg_proc p
JOIN pg_namespace n ON n.oid = p.pronamespace
WHERE p.proname = '<function_name>'
ORDER BY n.nspname, identity_arguments;Why it happens
What PostgreSQL is telling you
The mechanism behind the error, grounded in the official manual, not paraphrased.
PostgreSQL 18 Documentation, Appendix A. PostgreSQL Error Codes (Table A.1, Class 42, Syntax Error or Access Rule Violation)
42723 → duplicate_functionRead the full section on postgresql.org →
Recreating an existing function signature
A function 'add_one' with the same argument types already exists, so a plain CREATE FUNCTION raises 'function add_one already exists with same argument types'.The session continues normally
CREATE FUNCTION failed as a standalone statement, so nothing needs to be rolled back before the next query.Reproduce & verify
A real, single-session PostgreSQL reproduction
A literal transcript of SQL run against a live PostgreSQL instance in an isolated lab. The commands below are exactly what was executed.
- 1CREATE FUNCTION with a name and argument-type list that already exists.
- 2PostgreSQL matches the existing function by name and argument types.
- 3The duplicate is rejected with SQLSTATE 42723.
A migration re-declared an existing function without OR REPLACE and collided on the identical signature.
CREATE FUNCTION add_one(int) RETURNS int LANGUAGE sql AS 'SELECT $1 + 1';CREATE FUNCTION add_one(int) RETURNS int LANGUAGE sql AS 'SELECT $1 + 2';SELECT 'ok' AS session_after_error;What PostgreSQL actually returned
CREATE FUNCTIONERROR: function "add_one" already exists with same argument types session_after_error
---------------------
ok
(1 row)The definition applies cleanly with CREATE OR REPLACE.
Without this
Before: a duplicate CREATE FUNCTION aborts
With this, tested
After: CREATE OR REPLACE updates it
- A second operational test: exact SQL, raw output, measured result, and engineer notes
Card required. Cancel before day 7 and you are not charged.
Connected
Everything this error touches
Every page this SQLSTATE connects to: the concept that explains it, the runbooks that fix it, the parameters you tune to prevent it, and the sibling errors it travels with. All real cross-references. Jump straight in, or open the full interactive map.
Verification
- Last verified
- 2026-07-24 (isolated lab, PostgreSQL 18.4)
- Verification scope
- Verified against PostgreSQL 18.4 in an isolated lab environment
- Audit status
- reviewed
Went further?
Pro unlocks the second lab proof
Free page stops the bleeding. Pro adds the operational test, SQLSTATE audit, and deeper evidence, same error, more certainty.