11<!--
2- $PostgreSQL: pgsql/doc/src/sgml/ref/create_function.sgml,v 1.82 2008/12/04 17:51:26 petere Exp $
2+ $PostgreSQL: pgsql/doc/src/sgml/ref/create_function.sgml,v 1.83 2008/12/18 18:20:33 tgl Exp $
33-->
44
55<refentry id="SQL-CREATEFUNCTION">
@@ -21,7 +21,7 @@ $PostgreSQL: pgsql/doc/src/sgml/ref/create_function.sgml,v 1.82 2008/12/04 17:51
2121 <refsynopsisdiv>
2222<synopsis>
2323CREATE [ OR REPLACE ] FUNCTION
24- <replaceable class="parameter">name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [ { DEFAULT | = } <replaceable class="parameter">defexpr</replaceable>] [, ...] ] )
24+ <replaceable class="parameter">name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [ { DEFAULT | = } <replaceable class="parameter">defexpr</replaceable> ] [, ...] ] )
2525 [ RETURNS <replaceable class="parameter">rettype</replaceable>
2626 | RETURNS TABLE ( <replaceable class="parameter">colname</replaceable> <replaceable class="parameter">coltype</replaceable> [, ...] ) ]
2727 { LANGUAGE <replaceable class="parameter">langname</replaceable>
@@ -37,7 +37,7 @@ CREATE [ OR REPLACE ] FUNCTION
3737 [ WITH ( <replaceable class="parameter">attribute</replaceable> [, ...] ) ]
3838</synopsis>
3939 </refsynopsisdiv>
40-
40+
4141 <refsect1 id="sql-createfunction-description">
4242 <title>Description</title>
4343
@@ -133,7 +133,7 @@ CREATE [ OR REPLACE ] FUNCTION
133133
134134 <listitem>
135135 <para>
136- The data type(s) of the function's arguments (optionally
136+ The data type(s) of the function's arguments (optionally
137137 schema-qualified), if any. The argument types can be base, composite,
138138 or domain types, or can reference the type of a table column.
139139 </para>
@@ -160,10 +160,11 @@ CREATE [ OR REPLACE ] FUNCTION
160160 <listitem>
161161 <para>
162162 An expression to be used as default value if the parameter is
163- not specified. The expression has to be convertable to the
164- argument type of the parameter. All parameters after a
165- parameter with default value have to be parameters with default
166- values as well.
163+ not specified. The expression has to be coercible to the
164+ argument type of the parameter.
165+ Only input (including <literal>INOUT</>) parameters can have a default
166+ value. All input parameters following a
167+ parameter with a default value must have default values as well.
167168 </para>
168169 </listitem>
169170 </varlistentry>
@@ -173,7 +174,7 @@ CREATE [ OR REPLACE ] FUNCTION
173174
174175 <listitem>
175176 <para>
176- The return data type (optionally schema-qualified). The return type
177+ The return data type (optionally schema-qualified). The return type
177178 can be a base, composite, or domain type,
178179 or can reference the type of a table column.
179180 Depending on the implementation language it might also be allowed
@@ -496,6 +497,18 @@ CREATE FUNCTION foo(int, out text) ...
496497</programlisting>
497498 </para>
498499
500+ <para>
501+ Functions that have different argument type lists will not be considered
502+ to conflict at creation time, but if defaults are provided they might
503+ conflict in use. For example, consider
504+ <programlisting>
505+ CREATE FUNCTION foo(int) ...
506+ CREATE FUNCTION foo(int, int default 42) ...
507+ </programlisting>
508+ A call <literal>foo(10)</> will fail due to the ambiguity about which
509+ function should be called.
510+ </para>
511+
499512 <para>
500513 When repeated <command>CREATE FUNCTION</command> calls refer to
501514 the same object file, the file is only loaded once per session.
@@ -664,7 +677,6 @@ COMMIT;
664677
665678 </refsect1>
666679
667-
668680 <refsect1 id="sql-createfunction-compat">
669681 <title>Compatibility</title>
670682
0 commit comments