From 8394e4723a0b287019eace79e68c4bb917717eaa Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 26 Oct 2001 21:17:03 +0000 Subject: [PATCH] More cleanup of CREATE FUNCTION examples. --- doc/src/sgml/ref/create_function.sgml | 14 +++++++++----- doc/src/sgml/ref/create_language.sgml | 10 +++++----- doc/src/sgml/ref/createlang.sgml | 10 ++++++---- doc/src/sgml/ref/drop_language.sgml | 6 ++---- doc/src/sgml/xfunc.sgml | 16 ++++++++-------- doc/src/sgml/xindex.sgml | 14 ++++++++------ doc/src/sgml/xoper.sgml | 6 +++--- doc/src/sgml/xtypes.sgml | 8 ++++---- 8 files changed, 45 insertions(+), 39 deletions(-) diff --git a/doc/src/sgml/ref/create_function.sgml b/doc/src/sgml/ref/create_function.sgml index b151f723a7..543733620b 100644 --- a/doc/src/sgml/ref/create_function.sgml +++ b/doc/src/sgml/ref/create_function.sgml @@ -1,5 +1,5 @@ @@ -295,14 +295,16 @@ SELECT one() AS answer; The next example creates a C function by calling a routine from a - user-created shared library. This particular routine calculates a - check digit and returns TRUE if the check digit in the function + user-created shared library named funcs.so (the extension + may vary across platforms). The shared library file is sought in the + server's dynamic library search path. This particular routine calculates + a check digit and returns TRUE if the check digit in the function parameters is correct. It is intended for use in a CHECK constraint. CREATE FUNCTION ean_checkdigit(char, char) RETURNS boolean - AS '/usr1/proj/bray/sql/funcs.so' LANGUAGE C; + AS 'funcs' LANGUAGE C; CREATE TABLE product ( id char(8) PRIMARY KEY, @@ -318,7 +320,9 @@ CREATE TABLE product ( This example creates a function that does type conversion between the user-defined type complex, and the internal type point. The function is implemented by a dynamically loaded object that was - compiled from C source. For PostgreSQL to + compiled from C source (we illustrate the now-deprecated alternative + of specifying the exact pathname to the shared object file). + For PostgreSQL to find a type conversion function automatically, the SQL function has to have the same name as the return type, and so overloading is unavoidable. The function name is overloaded by using the second diff --git a/doc/src/sgml/ref/create_language.sgml b/doc/src/sgml/ref/create_language.sgml index b6af18b1bc..ad88c3f84c 100644 --- a/doc/src/sgml/ref/create_language.sgml +++ b/doc/src/sgml/ref/create_language.sgml @@ -1,5 +1,5 @@ @@ -171,7 +171,7 @@ ERROR: PL handler function funcnamePostgreSQL distribution, the program should be used, which will also + linkend="app-createlang"> script should be used, which will also install the correct call handler. (createlang will call CREATE LANGUAGE internally.) @@ -183,7 +183,7 @@ ERROR: PL handler function funcname Use , or better yet the program, to drop procedural languages. + linkend="app-droplang"> script, to drop procedural languages. @@ -210,7 +210,7 @@ ERROR: PL handler function funcname At present, the definition of a procedural language cannot be - changed once is has been created. + changed once it has been created. @@ -222,7 +222,7 @@ ERROR: PL handler function funcname CREATE FUNCTION plsample_call_handler () RETURNS opaque - AS '/usr/local/pgsql/lib/plsample.so' + AS '$libdir/plsample' LANGUAGE C; CREATE LANGUAGE plsample HANDLER plsample_call_handler; diff --git a/doc/src/sgml/ref/createlang.sgml b/doc/src/sgml/ref/createlang.sgml index f0abeeae22..c4d215d7c7 100644 --- a/doc/src/sgml/ref/createlang.sgml +++ b/doc/src/sgml/ref/createlang.sgml @@ -1,5 +1,5 @@ @@ -44,7 +44,8 @@ Postgres documentation langname - Specifies the name of the backend programming language to be defined. + Specifies the name of the procedural programming language to be + defined. createlang will prompt for langname if it is not specified on the command line. @@ -56,7 +57,7 @@ Postgres documentation -d, --dbname dbname - Specifies which database the language should be added. + Specifies to which database the language should be added. @@ -85,7 +86,8 @@ Postgres documentation Specifies the directory in which the language interpreter is - to be found. This is normally found automatically. + to be found. Use of this option is deprecated; the directory + is normally found automatically. diff --git a/doc/src/sgml/ref/drop_language.sgml b/doc/src/sgml/ref/drop_language.sgml index 5f4b218bfa..2f85007af8 100644 --- a/doc/src/sgml/ref/drop_language.sgml +++ b/doc/src/sgml/ref/drop_language.sgml @@ -1,13 +1,11 @@ - - DROP LANGUAGE - + DROP LANGUAGE SQL - Language Statements diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml index dc29f907ff..529bdec3ef 100644 --- a/doc/src/sgml/xfunc.sgml +++ b/doc/src/sgml/xfunc.sgml @@ -1,5 +1,5 @@ @@ -1054,25 +1054,25 @@ concat_text(text *arg1, text *arg2) CREATE FUNCTION add_one(int4) RETURNS int4 - AS 'PGROOT/tutorial/funcs' LANGUAGE 'c' + AS 'PGROOT/tutorial/funcs' LANGUAGE C WITH (isStrict); -- note overloading of SQL function name add_one() CREATE FUNCTION add_one(float8) RETURNS float8 AS 'PGROOT/tutorial/funcs', 'add_one_float8' - LANGUAGE 'c' WITH (isStrict); + LANGUAGE C WITH (isStrict); CREATE FUNCTION makepoint(point, point) RETURNS point - AS 'PGROOT/tutorial/funcs' LANGUAGE 'c' + AS 'PGROOT/tutorial/funcs' LANGUAGE C WITH (isStrict); CREATE FUNCTION copytext(text) RETURNS text - AS 'PGROOT/tutorial/funcs' LANGUAGE 'c' + AS 'PGROOT/tutorial/funcs' LANGUAGE C WITH (isStrict); CREATE FUNCTION concat_text(text, text) RETURNS text - AS 'PGROOT/tutorial/funcs' LANGUAGE 'c' + AS 'PGROOT/tutorial/funcs' LANGUAGE C WITH (isStrict); @@ -1358,8 +1358,8 @@ c_overpaid(PG_FUNCTION_ARGS) CREATE FUNCTION c_overpaid(emp, int4) RETURNS bool -AS 'PGROOT/tutorial/obj/funcs' -LANGUAGE 'c'; +AS 'PGROOT/tutorial/funcs' +LANGUAGE C; diff --git a/doc/src/sgml/xindex.sgml b/doc/src/sgml/xindex.sgml index 155c6d5fc0..66b39eb0bf 100644 --- a/doc/src/sgml/xindex.sgml +++ b/doc/src/sgml/xindex.sgml @@ -1,5 +1,5 @@ @@ -313,7 +313,9 @@ SELECT oid, * Suppose the code that implements these functions is stored in the file - PGROOT/src/tutorial/complex.c. + PGROOT/tutorial/complex.c, + which we have compiled into + PGROOT/tutorial/complex.so. @@ -339,8 +341,8 @@ SELECT oid, * CREATE FUNCTION complex_abs_eq(complex, complex) RETURNS bool - AS 'PGROOT/tutorial/obj/complex.so' - LANGUAGE 'c'; + AS 'PGROOT/tutorial/complex' + LANGUAGE C; @@ -489,8 +491,8 @@ CREATE OPERATOR = ( CREATE FUNCTION complex_abs_cmp(complex, complex) RETURNS int4 - AS 'PGROOT/tutorial/obj/complex.so' - LANGUAGE 'c'; + AS 'PGROOT/tutorial/complex' + LANGUAGE C; SELECT oid, proname FROM pg_proc WHERE proname = 'complex_abs_cmp'; diff --git a/doc/src/sgml/xoper.sgml b/doc/src/sgml/xoper.sgml index f4ea5c6e47..e2358dfd63 100644 --- a/doc/src/sgml/xoper.sgml +++ b/doc/src/sgml/xoper.sgml @@ -1,5 +1,5 @@ @@ -38,8 +38,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/xoper.sgml,v 1.14 2001/09/13 15:55:23 peter CREATE FUNCTION complex_add(complex, complex) RETURNS complex - AS '$PWD/obj/complex.so' - LANGUAGE 'c'; + AS 'PGROOT/tutorial/complex' + LANGUAGE C; CREATE OPERATOR + ( leftarg = complex, diff --git a/doc/src/sgml/xtypes.sgml b/doc/src/sgml/xtypes.sgml index b9093253d4..f4a8c4c4a9 100644 --- a/doc/src/sgml/xtypes.sgml +++ b/doc/src/sgml/xtypes.sgml @@ -110,13 +110,13 @@ complex_out(Complex *complex) CREATE FUNCTION complex_in(opaque) RETURNS complex - AS 'PGROOT/tutorial/obj/complex.so' - LANGUAGE 'c'; + AS 'PGROOT/tutorial/complex' + LANGUAGE C; CREATE FUNCTION complex_out(opaque) RETURNS opaque - AS 'PGROOT/tutorial/obj/complex.so' - LANGUAGE 'c'; + AS 'PGROOT/tutorial/complex' + LANGUAGE C; CREATE TYPE complex ( internallength = 16,