From 1ac838edba409abe87649c6820a9ee492cb1a1c5 Mon Sep 17 00:00:00 2001 From: "Thomas G. Lockhart" Date: Mon, 14 Jun 1999 07:37:05 +0000 Subject: Minor updates for release. Split reference pages for CREATE TABLE AS and SELECT INTO to allow psgml (the emacs parser) to handle parsing. --- doc/src/sgml/ref/create_function.sgml | 291 +++++++++++++++++----------------- 1 file changed, 146 insertions(+), 145 deletions(-) (limited to 'doc/src/sgml/ref/create_function.sgml') diff --git a/doc/src/sgml/ref/create_function.sgml b/doc/src/sgml/ref/create_function.sgml index 482393ec0ab..3dc37e3380d 100644 --- a/doc/src/sgml/ref/create_function.sgml +++ b/doc/src/sgml/ref/create_function.sgml @@ -1,173 +1,173 @@ - - - + + + CREATE FUNCTION - - SQL - Language Statements - - - + + SQL - Language Statements + + + CREATE FUNCTION - - + + Defines a new function - + - - - 1998-09-09 - - + + + 1998-09-09 + + CREATE FUNCTION name ( [ ftype [, ...] ] ) RETURNS rtype AS definition LANGUAGE 'langname' - + - - - 1998-09-09 - - + <refsect2 id="R2-SQL-CREATEFUNCTION-1"> + <refsect2info> + <date>1998-09-09</date> + </refsect2info> + <title> Inputs - - - - - + + + + + name - - - + + + The name of a function to create. - - - - - + + + + + ftype - - - + + + The data type of function arguments. - - - - - + + + + + rtype - - - + + + The return data type. - - - - - + + + + + definition - - - + + + 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. - - - - - + + + + + langname - - - + + + may be 'C', 'sql', 'internal' or 'plname', where 'plname' is the name of a created procedural language. See CREATE LANGUAGE for details. - - - + + + - + - - - 1998-09-09 - - + <refsect2 id="R2-SQL-CREATEFUNCTION-2"> + <refsect2info> + <date>1998-09-09</date> + </refsect2info> + <title> Outputs - - + + - - - - CREATE - - - + + + + CREATE + + + This is returned if the command completes successfully. - + - - + + - - - 1998-09-09 - - + <refsect1 id="R1-SQL-CREATEFUNCTION-1"> + <refsect1info> + <date>1998-09-09</date> + </refsect1info> + <title> Description - - + + CREATE FUNCTION allows a Postgres user to register a function with a database. Subsequently, this user is treated as the owner of the function. - + - - - 1998-09-09 - - + <refsect2 id="R2-SQL-CREATEFUNCTION-3"> + <refsect2info> + <date>1998-09-09</date> + </refsect2info> + <title> Notes - - + + Refer to the chapter on functions in the PostgreSQL Programmer's Guide for further information. - - + + 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 @@ -178,18 +178,18 @@ in the PostgreSQL Programmer's Guide 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. - - + + - - + <refsect1 id="R1-SQL-CREATEFUNCTION-2"> + <title> Usage - - + + To create a simple SQL function: - - + + CREATE FUNCTION one() RETURNS int4 AS 'SELECT 1 AS RESULT' LANGUAGE 'sql'; @@ -201,7 +201,7 @@ in the PostgreSQL Programmer's Guide ------ 1 - + To create a C function, calling a routine from a user-created shared library. This particular routine calculates a check @@ -211,44 +211,44 @@ in the PostgreSQL Programmer's Guide CREATE FUNCTION ean_checkdigit(bpchar, bpchar) RETURNS bool - AS '/usr1/proj/bray/sql/funcs.so' LANGUAGE 'c'; + AS '/usr1/proj/bray/sql/funcs.so' LANGUAGE 'c'; - CREATE TABLE product - ( - id char(8) PRIMARY KEY, - eanprefix char(8) CHECK (eanprefix ~ '[0-9]{2}-[0-9]{5}') - REFERENCES brandname(ean_prefix), - eancode char(6) CHECK (eancode ~ '[0-9]{6}'), - CONSTRAINT ean CHECK (ean_checkdigit(eanprefix, eancode)) - ); + CREATE TABLE product ( + id char(8) PRIMARY KEY, + eanprefix char(8) CHECK (eanprefix ~ '[0-9]{2}-[0-9]{5}') + REFERENCES brandname(ean_prefix), + eancode char(6) CHECK (eancode ~ '[0-9]{6}'), + CONSTRAINT ean CHECK (ean_checkdigit(eanprefix, eancode)) + ); + - + - - + <refsect1 id="R1-SQL-CREATEFUNCTION-3"> + <title> Bugs - - + + A C function cannot return a set of values. - - + + - - + <refsect1 id="R1-SQL-CREATEFUNCTION-4"> + <title> Compatibility - - + + CREATE FUNCTION is a Postgres language extension. - + - - - 1998-09-09 - - + <refsect2 id="R2-SQL-CREATEFUNCTION-4"> + <refsect2info> + <date>1998-09-09</date> + </refsect2info> + <title> SQL/PSM - + @@ -264,7 +264,8 @@ has not yet happened, but it is hoped that PSM will SQL/PSM CREATE FUNCTION has the following syntax: CREATE FUNCTION name - ( [ [ IN | OUT | INOUT ] parm type [, ...] ] ) + ( [ [ IN | OUT | INOUT ] etereable> type [, ...] ] ) RETURNS rtype LANGUAGE 'langname' ESPECIFIC routine @@ -274,12 +275,12 @@ CREATE FUNCTION name - +