Function and aggregate signatures
Each user-defined function and aggregate has a signature;
that is, a unique identification that is of the form <udx-name>(<argument
type name list>).
Signatures must be unique within the same database, and they cannot
duplicate the signature of another UDF, UDA, or a built-in function
or aggregate. The <argument type name list> component
does not consider data type sizes to be differentiators. For example,
you cannot create two functions called Myfunc( numeric(3,2)
) and Myfunc( numeric(4,1) ) in the same
database.
Note: If your system supports multiple schemas, you could
create functions that share the same signature in different schemas
of the same database. As a best practice, avoid creating duplicates
of the same function in different schemas; you can use fully qualified
names to reference a function in a different schema if the user has
privileges to access the other schema. This can help to reduce the
overhead to maintain multiple copies of the same function.
If there are common use-cases where a function or aggregate must
accept different-sized strings or numerics, you can design the UDX
to accept the largest of the possible values (such as the customername example
in the previous section), or you can create a UDX with a different
name to process a different data size. For example:
MYDB.SCHEMA(MYUSER)=> CREATE FUNCTION CustomerNameShort(varchar(256))
RETURNS int4 LANGUAGE CPP PARAMETER STYLE NPSGENERIC API VERSION 2
EXTERNAL CLASS NAME 'CCustomerName'
EXTERNAL HOST OBJECT '/home/nz/udx_files/customername.o_x86'
EXTERNAL SPU OBJECT '/home/nz/udx_files/customername.o_spu10';