2009
MySQLERRORNotableUDFHIGH confidence

Function already exists

Production Risk

Low — UDF creation is rejected.

What this means

An attempt was made to create a User-Defined Function that already exists in the mysql.func table. UDF names must be unique across the server.

Why it happens
  1. 1CREATE FUNCTION issued for a UDF name that is already registered.
  2. 2Duplicate UDF installation script run multiple times.
How to reproduce
trigger — this will error
trigger — this will error
CREATE FUNCTION my_func RETURNS STRING SONAME 'myfunc.so'; -- run twice

expected output

ERROR 2009 (HY000): Function 'my_func' already exists.

Fix

Drop the existing UDF before recreating

Drop the existing UDF before recreating
DROP FUNCTION IF EXISTS my_func;
CREATE FUNCTION my_func RETURNS STRING SONAME 'myfunc.so';

Why this works

Dropping first ensures a clean reinstall of the UDF.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 2009 ER_UDF_EXISTS

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MySQL errors