From c9f8ab6fba29e1e09b6cf79881786bd0779b6e2b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 20 May 1999 02:57:15 +0000 Subject: [PATCH] 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). --- doc/src/sgml/ref/create_function.sgml | 38 ++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/doc/src/sgml/ref/create_function.sgml b/doc/src/sgml/ref/create_function.sgml index f5a27adb30..482393ec0a 100644 --- a/doc/src/sgml/ref/create_function.sgml +++ b/doc/src/sgml/ref/create_function.sgml @@ -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. +