Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c9f8ab6

Browse files
committed
Update CREATE FUNCTION docs: mention use of AS clause with
INTERNAL functions, add a warning about trying to overload function names for dynamically loaded C functions (from old man page).
1 parent e68abfb commit c9f8ab6

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

doc/src/sgml/ref/create_function.sgml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<SYNOPSIS>
2121
CREATE FUNCTION <replaceable class="parameter">name</replaceable> ( [ <replaceable class="parameter">ftype</replaceable> [, ...] ] )
2222
RETURNS <replaceable class="parameter">rtype</replaceable>
23-
AS <replaceable class="parameter">path</replaceable>
23+
AS <replaceable class="parameter">definition</replaceable>
2424
LANGUAGE '<replaceable class="parameter">langname</replaceable>'
2525
</SYNOPSIS>
2626

@@ -65,12 +65,13 @@ CREATE FUNCTION <replaceable class="parameter">name</replaceable> ( [ <replaceab
6565
</VARLISTENTRY>
6666
<VARLISTENTRY>
6767
<TERM>
68-
<replaceable class="parameter">path</replaceable>
68+
<replaceable class="parameter">definition</replaceable>
6969
</TERM>
7070
<LISTITEM>
7171
<PARA>
72-
May be either an SQL-query or an absolute path to an
73-
object file.
72+
A string defining the function; the meaning depends on the language.
73+
It may be an internal function name, the path to an object file,
74+
an SQL query, or text in a procedural language.
7475
</PARA>
7576
</LISTITEM>
7677
</VARLISTENTRY>
@@ -149,6 +150,35 @@ in the <citetitle>PostgreSQL Programmer's Guide</citetitle>
149150
Use <command>DROP FUNCTION</command>
150151
to drop user-defined functions.
151152
</PARA>
153+
154+
<PARA>
155+
<productname>Postgres</productname> allows function "overloading";
156+
that is, the same name can be used for several different functions
157+
so long as they have distinct argument types. This facility must be
158+
used with caution for INTERNAL and C-language functions, however.
159+
</PARA>
160+
161+
<PARA>
162+
Two INTERNAL functions cannot have the same C name without causing
163+
errors at link time. To get around that, give them different C names
164+
(for example, use the argument types as part of the C names), then
165+
specify those names in the AS clause of <command>CREATE FUNCTION</command>.
166+
If the AS clause is left empty then <command>CREATE FUNCTION</command>
167+
assumes the C name of the function is the same as the SQL name.
168+
</PARA>
169+
170+
<PARA>
171+
For dynamically-loaded C functions, the SQL name of the function must
172+
be the same as the C function name, because the AS clause is used to
173+
give the path name of the object file containing the C code. In this
174+
situation it is best not to try to overload SQL function names. It
175+
might work to load a C function that has the same C name as an internal
176+
function or another dynamically-loaded function --- or it might not.
177+
On some platforms the dynamic loader may botch the load in interesting
178+
ways if there is a conflict of C function names. So, even if it works
179+
for you today, you might regret overloading names later when you try
180+
to run the code somewhere else.
181+
</PARA>
152182
</REFSECT2>
153183
</refsect1>
154184

0 commit comments

Comments
 (0)