|
20 | 20 | <SYNOPSIS>
|
21 | 21 | CREATE FUNCTION <replaceable class="parameter">name</replaceable> ( [ <replaceable class="parameter">ftype</replaceable> [, ...] ] )
|
22 | 22 | RETURNS <replaceable class="parameter">rtype</replaceable>
|
23 |
| - AS <replaceable class="parameter">path</replaceable> |
| 23 | + AS <replaceable class="parameter">definition</replaceable> |
24 | 24 | LANGUAGE '<replaceable class="parameter">langname</replaceable>'
|
25 | 25 | </SYNOPSIS>
|
26 | 26 |
|
@@ -65,12 +65,13 @@ CREATE FUNCTION <replaceable class="parameter">name</replaceable> ( [ <replaceab
|
65 | 65 | </VARLISTENTRY>
|
66 | 66 | <VARLISTENTRY>
|
67 | 67 | <TERM>
|
68 |
| - <replaceable class="parameter">path</replaceable> |
| 68 | + <replaceable class="parameter">definition</replaceable> |
69 | 69 | </TERM>
|
70 | 70 | <LISTITEM>
|
71 | 71 | <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. |
74 | 75 | </PARA>
|
75 | 76 | </LISTITEM>
|
76 | 77 | </VARLISTENTRY>
|
@@ -149,6 +150,35 @@ in the <citetitle>PostgreSQL Programmer's Guide</citetitle>
|
149 | 150 | Use <command>DROP FUNCTION</command>
|
150 | 151 | to drop user-defined functions.
|
151 | 152 | </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> |
152 | 182 | </REFSECT2>
|
153 | 183 | </refsect1>
|
154 | 184 |
|
|
0 commit comments