SQLSTATE 42723 ERROR Class 42: Syntax Error or Access Rule Violation

duplicate_function function … already exists with same argument types — 42723

PostgreSQL error "function … already exists with same argument types" (SQLSTATE 42723): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

A CREATE FUNCTION tried to create a function whose name and argument types match an existing one. PostgreSQL raises SQLSTATE 42723 (duplicate_function).

  • A function with that signature already exists.
  • Functions are identified by name plus argument types.
  • Common when forgetting OR REPLACE.

What the server log shows

ERROR:  function get_total(integer) already exists with same argument types

Why PostgreSQL raises this — what the manual says

the CREATE FUNCTION reference (Description):

“CREATE OR REPLACE FUNCTION will either create a new function, or replace an existing definition.”

PostgreSQL identifies functions by name and input argument types (overloading). Creating one with an identical signature collides with the existing function, so it reports 42723.

Common causes

  • Creating a function without OR REPLACE when it already exists.
  • Re-running a migration.
  • An identical signature to an existing overload.

How to fix it

  1. Use CREATE OR REPLACE FUNCTION to update the body.
  2. Change the argument types if you intend a new overload.
  3. Drop the existing function first if you must change its return type.

Related & next steps

Reference: PostgreSQL 18 — CREATE FUNCTION.

Was this helpful?