5
Overloading
Several routines with the same name
routines differ in input parameter types;
types of the return value and output parameters are ignored
an appropriate routine is selected during execution based on the actual
argument types
CREATE OR REPLACE command
for new combinations of input parameter types, creates a new overloaded
routine
for existing combinations of input parameter types, changes the
corresponding routine, but not the type of the return value
Overloading is the ability to use one and the same name for several
routines (functions or procedures), which differ in types of IN and INOUT
parameters. In other words, a routine signature consists of its name and
types of its input parameters.
When calling a routine, PostgreSQL finds its version that corresponds to the
passed arguments. There might be situations when an appropriate routine
cannot be determined unambiguously; in this case, a run-time error occurs.
You have to take overloading into account when executing CREATE OR
REPLACE (FUNCTION or PROCEDURE). If input parameter types differ from
those used by already existing routines, a new overloaded routine will be
created. Besides, when applied to functions, this command does not allow
changing types of the output parameters and the return value type.
So you should delete and recreate the routine if required, but it won’t be the
same routine anymore. When deleting an old function, you also have to
delete all views, triggers, and other objects that depend on it
(DROP FUNCTION ... CASCADE).