Update CREATE FUNCTION docs: mention use of AS clause with
authorTom Lane
Thu, 20 May 1999 02:57:15 +0000 (02:57 +0000)
committerTom Lane
Thu, 20 May 1999 02:57:15 +0000 (02:57 +0000)
INTERNAL functions, add a warning about trying to overload function names
for dynamically loaded C functions (from old man page).

doc/src/sgml/ref/create_function.sgml

index f5a27adb308cce19baa161b329e0218782b9e225..482393ec0ab96ca17bf0d9d54230d780b9c48a86 100644 (file)
@@ -20,7 +20,7 @@
   
 CREATE FUNCTION name ( [ ftype [, ...] ] )
     RETURNS rtype
-    AS path
+    AS definition
     LANGUAGE 'langname'
   
   
@@ -65,12 +65,13 @@ CREATE FUNCTION name ( [ 
    
    
     
-     path
+     definition
       
       
        
-   May be either an SQL-query or an absolute path to an
-   object file.
+   A string defining the function; the meaning depends on the language.
+   It may be an internal function name, the path to an object file,
+   an SQL query, or text in a procedural language.
        
       
      
@@ -149,6 +150,35 @@ in the PostgreSQL Programmer's Guide
     Use DROP FUNCTION
     to drop user-defined functions.
    
+
+  
+   Postgres allows function "overloading";
+   that is, the same name can be used for several different functions
+   so long as they have distinct argument types.  This facility must be
+   used with caution for INTERNAL and C-language functions, however.
+  
+
+  
+   Two INTERNAL functions cannot have the same C name without causing
+   errors at link time.  To get around that, give them different C names
+   (for example, use the argument types as part of the C names), then
+   specify those names in the AS clause of CREATE FUNCTION.
+   If the AS clause is left empty then CREATE FUNCTION
+   assumes the C name of the function is the same as the SQL name.
+  
+
+  
+   For dynamically-loaded C functions, the SQL name of the function must
+   be the same as the C function name, because the AS clause is used to
+   give the path name of the object file containing the C code.  In this
+   situation it is best not to try to overload SQL function names.  It
+   might work to load a C function that has the same C name as an internal
+   function or another dynamically-loaded function --- or it might not.
+   On some platforms the dynamic loader may botch the load in interesting
+   ways if there is a conflict of C function names.  So, even if it works
+   for you today, you might regret overloading names later when you try
+   to run the code somewhere else.
+