RefLib

Reference library for AI

Back

postgresql_16:7.1.65.3 Overloading

PostgreSQL 16 > Reference > SQL Commands > CREATE FUNCTION > Overloading

PostgreSQL allows function *overloading*; that is, the same name can be used for several different functions so long as they have distinct input argument types. Whether or not you use it, this capability entails security precautions when calling functions in databases where some users mistrust other users; see (see postgresql_16:3.7.3).

Two functions are considered the same if they have the same names and *input* argument types, ignoring any OUT parameters. Thus for example these declarations conflict: CREATE FUNCTION foo(int) ... CREATE FUNCTION foo(int, out text) ...

Functions that have different argument type lists will not be considered to conflict at creation time, but if defaults are provided they might conflict in use. For example, consider CREATE FUNCTION foo(int) ... CREATE FUNCTION foo(int, int default 42) ... A call foo(10) will fail due to the ambiguity about which function should be called.

Back