select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

SQLSTATE / CLASS 42 · SYNTAX ERROR OR ACCESS RULE VIOLATION

duplicate_function

SQLSTATE
42723
Condition name
duplicate_function
Class
Syntax Error or Access Rule Violation
Source macro
ERRCODE_DUPLICATE_FUNCTION
Evidence
Observed at runtime in the source evidence
Analysis & operational context

English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗

<h1>42723 — Duplicate function</h1>

At a glance

42723 is duplicate_function: a function definition repeats the same schema, name, and input argument types. Output types do not create another overload.

Meaning

The fixed catalog path reports function "%s" already exists with same argument types. Inspect pg_proc, pg_get_function_identity_arguments, and the result contract. This is a definition collision, unlike 42725, which occurs when call resolution has multiple candidates; the selected autocommit error leaves IDLE.

Diagnosis

Inspect pg_proc with pg_get_function_identity_arguments and make the schema explicit. Decide whether the migration intends a new input signature or replacement of an owned function; output types do not disambiguate identity.

Response

Use a new input signature for a genuinely different API. Use CREATE OR REPLACE FUNCTION only when replacing the owned function is intentional and its return contract stays compatible; it is not a safe input-type migration. In an explicit transaction, the duplicate definition leaves INERROR; roll back or return to a suitable savepoint before retrying. The selected autocommit path returns to IDLE.

Observed diagnostics

The pg_proc.c group is explicit ERROR with the fixed primary template and no detail or hint.

Representative case

The runner creates duplicate_function(integer), repeats that signature, then deliberately uses CREATE OR REPLACE and verifies the result 2.

CREATE FUNCTION syntax_schema.duplicate_function(integer) RETURNS integer LANGUAGE SQL AS 'SELECT $1';
CREATE FUNCTION syntax_schema.duplicate_function(integer) RETURNS integer LANGUAGE SQL AS 'SELECT $1';
CREATE OR REPLACE FUNCTION syntax_schema.duplicate_function(integer) RETURNS integer LANGUAGE SQL AS 'SELECT $1 + 1';
SELECT syntax_schema.duplicate_function(1);

The selected 18.6 and 10.21 runs passed SQLSTATE, severity, state/recovery, repair, cleanup, and isolated-target stop assertions. See case JSON and authored evidence; private manifest and registry hashes are recorded there.

Versions

The locked catalogue contains this condition from the 7.4 presence bound through the listed snapshots. The selected natural case passed on PostgreSQL 18.6 and 10.21; that bounded result does not infer every intermediate release or every source branch.

Sources

  • src.errcodes.REL_18_6 — fixed definition at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.duplicate-function.18.6src/backend/catalog/pg_proc.c lines 400–403 at 724edf9bde9d356724ad384a2e196edc3c9f80f7; blob SHA-256 77a883995e5fadf17fae68722043beb43115e685e8082b2b7256d92312528a5a (source).
  • src.duplicate-function.10.23src/backend/catalog/pg_proc.c lines 398–401 at 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; blob SHA-256 96ddd186536c24018d3e29fd7e8f7384543c89ede83c81f673dc013fdd23b0fe (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
  • manifest.42723 / snippet-registry.42723 — hashes are recorded in evidence/42723.json and each runtime record.

Source evidence

Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.

42723 is the duplicate_function condition in Class 42.

Method: Read fixed errcodes.txt and locked catalogue metadata.

Limits: Identity does not identify every backend call that can reuse this SQLSTATE.

src.errcodes.REL_18_6

The selected duplicate_function_signature follows a resolved PostgreSQL source-call group; other branches can use different dynamic fields.

Method: Trace the REL_18_6 and REL_10_23 source-call records at the locked commits.

Limits: This is one mechanism boundary, not an exhaustive inventory of the code.

src.duplicate-function.18.6 src.duplicate-function.10.23

The selected duplicate_function_signature passed on isolated PostgreSQL 18.6 and 10.21 targets.

Method: Run the shared SQL registry and inspect SQLSTATE, severity, state, repair, cleanup, and target stop.

Limits: Scope is limited to these statements, psycopg, and two versions.

manifest.42723 snippet-registry.42723

The locked catalogue records 42723 from the 7.4 presence bound through the listed snapshots; runtime scope is 18.6 and 10.21.

Method: Read generated facts, fixed calls, and selected summaries.

Limits: Definition presence is not an exact behavioral introduction; two runtime versions do not prove every intermediate behavior.

src.errcodes.REL_18_6 src.calls.REL_18_6 src.calls.REL_10_23

Message templates

explicit ERROR · message.duplicate_function_signature

Primary

function "%s" already exists with same argument types

Reproduction & repair cases

duplicate_function_signature · PG 10, 18

Preconditions

  • A runner-owned disposable target is provisioned.

Trigger: Create a function and repeat the same name and integer argument signature.

Expected assertions

  • SQLSTATE is 42723 with the same-argument-types message
  • The failed autocommit session remains IDLE
  • CREATE OR REPLACE with the intentional same signature returns the repaired value

Repair: Choose a new signature or use CREATE OR REPLACE only when replacing the owned function is intentional.

Cleanup: Drop the runner schema and its functions.

Recorded runtime evidence

18.6 (Homebrew) · passed

Run: syntax2-42723-latest

{
  "diagnostic": {
    "text": "function \"duplicate_function\" already exists with same argument types",
    "context": null,
    "severity": "ERROR",
    "sqlstate": "42723",
    "table_name": null,
    "column_name": null,
    "schema_name": null,
    "source_file": "pg_proc.c",
    "source_line": "403",
    "message_hint": null,
    "datatype_name": null,
    "exception_type": "DuplicateFunction",
    "internal_query": null,
    "message_detail": null,
    "constraint_name": null,
    "message_primary": "function \"duplicate_function\" already exists with same argument types",
    "source_function": "ProcedureCreate",
    "internal_position": null,
    "statement_position": null,
    "severity_nonlocalized": "ERROR"
  },
  "repair_value": 2,
  "failed_status": "IDLE",
  "repair_status": "IDLE",
  "connection_autocommit": true
}
10.21 (Debian 10.21-1.pgdg90+1) · passed

Run: syntax2-42723-pg10

{
  "diagnostic": {
    "text": "function \"duplicate_function\" already exists with same argument types",
    "context": null,
    "severity": "ERROR",
    "sqlstate": "42723",
    "table_name": null,
    "column_name": null,
    "schema_name": null,
    "source_file": "pg_proc.c",
    "source_line": "401",
    "message_hint": null,
    "datatype_name": null,
    "exception_type": "DuplicateFunction",
    "internal_query": null,
    "message_detail": null,
    "constraint_name": null,
    "message_primary": "function \"duplicate_function\" already exists with same argument types",
    "source_function": "ProcedureCreate",
    "internal_position": null,
    "statement_position": null,
    "severity_nonlocalized": "ERROR"
  },
  "repair_value": 2,
  "failed_status": "IDLE",
  "repair_status": "IDLE",
  "connection_autocommit": true
}

Definition snapshot: english-manuals:0de774f1e791a3d1d694d0246fb… · English manual source