Incident brief
Duplicate function parameter name
A function's named parameters must be distinct; declaring two parameters with the same name raises this invalid-function-definition error.
What lands in your log
ERROR: parameter name "a" used more than once
In 10 seconds
- What triggers it
- Declare a function with two parameters that share the same name.
- Fix
- Give each parameter a distinct name.
- Proof
- Reproduced on PostgreSQL 18.4 → A CREATE FUNCTION reproduces SQLSTATE 42P13; the repeated parameter name is rejected and the LINE points at it.
Fix
What to do right now
Application-level steps for this error.
- Give each parameter a distinct name.
- Rename the colliding parameter so the signature is unambiguous.
CREATE FUNCTION dup_param(a int, b int)
RETURNS int
LANGUAGE sql
AS 'SELECT a + b';
SELECT dup_param(1, 2);For this error
See this error live on the server
Run these against the affected instance to confirm the diagnosis before you act.
Duplicate function parameter name is fixed in the statement text. PostgreSQL stores no failed parse tree, so use the error POSITION against the exact SQL sent by the driver and inspect real column/function names.
Candidate columns on the referenced relations
Replace the relation array with the tables/aliases in the failing statement.
SELECT attrelid::regclass AS table_name, attnum, attname,
format_type(atttypid, atttypmod) AS data_type
FROM pg_attribute
WHERE attrelid = ANY (ARRAY[
to_regclass('<first_relation>'),
to_regclass('<second_relation>')
]::regclass[])
AND attnum > 0 AND NOT attisdropped
ORDER BY attname, table_name;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)
42P13 → invalid_function_definitionRead the full section on postgresql.org →
Declaring two parameters with one name
Two parameters are both named 'a', so PostgreSQL raises 'parameter name a used more than once'.The session continues normally
CREATE FUNCTION failed on its parameter check outside a transaction, leaving nothing to undo before the next statement.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.
- 1Declare a function with two parameters that share the same name.
- 2PostgreSQL validates the parameter list.
- 3The duplicate name is rejected with SQLSTATE 42P13.
A copy-paste left two function parameters with the same name and the definition would not compile.
-- The error is self-contained in one statement; no schema is required.
SELECT 'no schema needed' AS setup_note;CREATE FUNCTION dup_param(a int, a int) RETURNS int LANGUAGE sql AS 'SELECT 1';SELECT 'ok' AS session_after_error;What PostgreSQL actually returned
setup_note
------------------
no schema needed
(1 row)ERROR: parameter name "a" used more than once
LINE 1: CREATE FUNCTION dup_param(a int, a int) RETURNS int LANGUAGE...
^ session_after_error
---------------------
ok
(1 row)The function is created once each parameter name is unique.
Without this
Before: a repeated parameter name aborts
With this, tested
After: distinct names are accepted
- 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.
Related errors
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.