Commit 934c2134 authored by Peter Eisentraut's avatar Peter Eisentraut

Documentation cleanup

parent fa5c8a05
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ecpg.sgml,v 1.53 2003/10/17 18:57:00 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ecpg.sgml,v 1.54 2003/11/12 22:47:47 petere Exp $
--> -->
<chapter id="ecpg"> <chapter id="ecpg">
...@@ -284,7 +284,7 @@ EXEC SQL COMMIT; ...@@ -284,7 +284,7 @@ EXEC SQL COMMIT;
</para> </para>
<para> <para>
Single-row Select: Single-row select:
<programlisting> <programlisting>
EXEC SQL SELECT foo INTO :FooBar FROM table1 WHERE ascii = 'doodad'; EXEC SQL SELECT foo INTO :FooBar FROM table1 WHERE ascii = 'doodad';
</programlisting> </programlisting>
...@@ -359,7 +359,7 @@ EXEC SQL AT <replaceable>connection-name</replaceable> SELECT ...; ...@@ -359,7 +359,7 @@ EXEC SQL AT <replaceable>connection-name</replaceable> SELECT ...;
The second option is to execute a statement to switch the current The second option is to execute a statement to switch the current
connection. That statement is: connection. That statement is:
<programlisting> <programlisting>
SET CONNECTION <replaceable>connection-name</replaceable>; EXEC SQL SET CONNECTION <replaceable>connection-name</replaceable>;
</programlisting> </programlisting>
This option is particularly convenient if many statements are to be This option is particularly convenient if many statements are to be
executed on the same connection. executed on the same connection.
...@@ -392,7 +392,7 @@ SET CONNECTION <replaceable>connection-name</replaceable>; ...@@ -392,7 +392,7 @@ SET CONNECTION <replaceable>connection-name</replaceable>;
write the name of a C variable into the SQL statement, prefixed by write the name of a C variable into the SQL statement, prefixed by
a colon. For example: a colon. For example:
<programlisting> <programlisting>
INSERT INTO sometable VALUES (:v1, 'foo', :v2); EXEC SQL INSERT INTO sometable VALUES (:v1, 'foo', :v2);
</programlisting> </programlisting>
This statements refers to two C variables named This statements refers to two C variables named
<varname>v1</varname> and <varname>v2</varname> and also uses a <varname>v1</varname> and <varname>v2</varname> and also uses a
...@@ -592,7 +592,7 @@ EXEC SQL BEGIN DECLARE SECTION; ...@@ -592,7 +592,7 @@ EXEC SQL BEGIN DECLARE SECTION;
const char *stmt = "CREATE TABLE test1 (...);"; const char *stmt = "CREATE TABLE test1 (...);";
EXEC SQL END DECLARE SECTION; EXEC SQL END DECLARE SECTION;
EXECUTE IMMEDIATE :stmt; EXEC SQL EXECUTE IMMEDIATE :stmt;
</programlisting> </programlisting>
You may not execute statements that retrieve data (e.g., You may not execute statements that retrieve data (e.g.,
<command>SELECT</command>) this way. <command>SELECT</command>) this way.
...@@ -611,9 +611,9 @@ EXEC SQL BEGIN DECLARE SECTION; ...@@ -611,9 +611,9 @@ EXEC SQL BEGIN DECLARE SECTION;
const char *stmt = "INSERT INTO test1 VALUES(?, ?);"; const char *stmt = "INSERT INTO test1 VALUES(?, ?);";
EXEC SQL END DECLARE SECTION; EXEC SQL END DECLARE SECTION;
PREPARE mystmt FROM :stmt; EXEC SQL PREPARE mystmt FROM :stmt;
... ...
EXECUTE mystmt USING 42, 'foobar'; EXEC SQL EXECUTE mystmt USING 42, 'foobar';
</programlisting> </programlisting>
If the statement you are executing returns values, then add an If the statement you are executing returns values, then add an
<literal>INTO</literal> clause: <literal>INTO</literal> clause:
...@@ -624,9 +624,9 @@ int v1, v2; ...@@ -624,9 +624,9 @@ int v1, v2;
VARCHAR v3; VARCHAR v3;
EXEC SQL END DECLARE SECTION; EXEC SQL END DECLARE SECTION;
PREPARE mystmt FROM :stmt; EXEC SQL PREPARE mystmt FROM :stmt;
... ...
EXECUTE mystmt INTO v1, v2, v3 USING 37; EXEC SQL EXECUTE mystmt INTO v1, v2, v3 USING 37;
</programlisting> </programlisting>
An <command>EXECUTE</command> command may have an An <command>EXECUTE</command> command may have an
<literal>INTO</literal> clause, a <literal>USING</literal> clause, <literal>INTO</literal> clause, a <literal>USING</literal> clause,
...@@ -668,7 +668,7 @@ EXEC SQL DEALLOCATE PREPARE <replaceable>name</replaceable>; ...@@ -668,7 +668,7 @@ EXEC SQL DEALLOCATE PREPARE <replaceable>name</replaceable>;
EXEC SQL ALLOCATE DESCRIPTOR <replaceable>identifier</replaceable>; EXEC SQL ALLOCATE DESCRIPTOR <replaceable>identifier</replaceable>;
</programlisting> </programlisting>
The identifier serves as the <quote>variable name</quote> of the The identifier serves as the <quote>variable name</quote> of the
descriptor area. The scope of the allocated descriptor is WHAT?. descriptor area. <comment>The scope of the allocated descriptor is WHAT?.</comment>
When you don't need the descriptor anymore, you should deallocate When you don't need the descriptor anymore, you should deallocate
it: it:
<programlisting> <programlisting>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.25 2003/09/11 21:42:19 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.26 2003/11/12 22:47:47 petere Exp $
--> -->
<chapter id="extend"> <chapter id="extend">
...@@ -105,52 +105,74 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.25 2003/09/11 21:42:19 momj ...@@ -105,52 +105,74 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.25 2003/09/11 21:42:19 momj
<para> <para>
<productname>PostgreSQL</productname> data types are divided into base <productname>PostgreSQL</productname> data types are divided into base
types, composite types, domain types, and pseudo-types. types, composite types, domains, and pseudo-types.
</para> </para>
<sect2>
<title>Base Types</title>
<para> <para>
Base types are those, like <type>int4</type>, that are implemented Base types are those, like <type>int4</type>, that are
below the level of the <acronym>SQL</> language (typically in a low-level implemented below the level of the <acronym>SQL</> language
language such as C). They generally correspond to (typically in a low-level language such as C). They generally
what are often known as abstract data types. correspond to what are often known as abstract data types.
<productname>PostgreSQL</productname> <productname>PostgreSQL</productname> can only operate on such
can only operate on such types through functions provided types through functions provided by the user and only understands
by the user and only understands the behavior of such the behavior of such types to the extent that the user describes
types to the extent that the user describes them. Base types are them. Base types are further subdivided into scalar and array
further subdivided into scalar and array types. For each scalar type, types. For each scalar type, a corresponding array type is
a corresponding array type is automatically created that can hold automatically created that can hold variable-size arrays of that
variable-size arrays of that scalar type. scalar type.
</para> </para>
</sect2>
<sect2>
<title>Composite Types</title>
<para> <para>
Composite types, or row types, are created whenever the user creates a Composite types, or row types, are created whenever the user
table; it's also possible to define a <quote>stand-alone</> composite creates a table; it's also possible to define a
type with no associated table. A composite type is simply a list of <quote>stand-alone</> composite type with no associated table. A
base types with associated field names. A value of a composite type composite type is simply a list of base types with associated
is a row or record of field values. The user can access the component field names. A value of a composite type is a row or record of
fields from <acronym>SQL</> queries. field values. The user can access the component fields from
<acronym>SQL</> queries.
</para> </para>
</sect2>
<sect2>
<title>Domains</title>
<para> <para>
A domain type is based on a particular base A domain is based on a particular base type and for many purposes
type and for many purposes is interchangeable with its base type. is interchangeable with its base type. However, a domain may
However, a domain may have constraints that restrict its valid values have constraints that restrict its valid values to a subset of
to a subset of what the underlying base type would allow. Domains can what the underlying base type would allow.
be created by simple <acronym>SQL</> commands.
</para> </para>
<para> <para>
Finally, there are a few <quote>pseudo-types</> for special purposes. Domains can be created using the <acronym>SQL</> commands
Pseudo-types cannot appear as fields of tables or composite types, but <command>CREATE DOMAIN</command>. Their creation and use is not
they can be used to declare the argument and result types of functions. discussed in this chapter.
This provides a mechanism within the type system to identify special </para>
classes of functions. <xref </sect2>
<sect2>
<title>Pseudo-Types</title>
<para>
There are a few <quote>pseudo-types</> for special purposes.
Pseudo-types cannot appear as columns of tables or attributes of
composite types, but they can be used to declare the argument and
result types of functions. This provides a mechanism within the
type system to identify special classes of functions. <xref
linkend="datatype-pseudotypes-table"> lists the existing linkend="datatype-pseudotypes-table"> lists the existing
pseudo-types. pseudo-types.
</para> </para>
</sect2>
<sect2 id="extend-types-polymorphic"> <sect2 id="extend-types-polymorphic">
<title>Polymorphic Types and Functions</title> <title>Polymorphic Types</title>
<indexterm zone="extend-types-polymorphic"> <indexterm zone="extend-types-polymorphic">
<primary>polymorphic type</primary> <primary>polymorphic type</primary>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/install-win32.sgml,v 1.15 2003/11/04 09:55:38 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/install-win32.sgml,v 1.16 2003/11/12 22:47:47 petere Exp $
--> -->
<chapter id="install-win32"> <chapter id="install-win32">
...@@ -109,7 +109,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/install-win32.sgml,v 1.15 2003/11/04 09:55: ...@@ -109,7 +109,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/install-win32.sgml,v 1.15 2003/11/04 09:55:
<para> <para>
<application>psql</application> is compiled as a <quote>console <application>psql</application> is compiled as a <quote>console
application</>. As the Win32 console windows use a different application</>. As the Windows console windows use a different
encoding than the rest of the system, you must take special care encoding than the rest of the system, you must take special care
when using 8-bit characters at the <application>psql</application> when using 8-bit characters at the <application>psql</application>
prompt. When <application>psql</application> detects a problematic prompt. When <application>psql</application> detects a problematic
......
This diff is collapsed.
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/lobj.sgml,v 1.31 2003/11/01 01:56:29 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/lobj.sgml,v 1.32 2003/11/12 22:47:47 petere Exp $
--> -->
<chapter id="largeObjects"> <chapter id="largeObjects">
...@@ -299,7 +299,7 @@ int lo_unlink(PGconn *conn, Oid lobjId); ...@@ -299,7 +299,7 @@ int lo_unlink(PGconn *conn, Oid lobjId);
</sect1> </sect1>
<sect1 id="lo-funcs"> <sect1 id="lo-funcs">
<title>Server-side Functions</title> <title>Server-Side Functions</title>
<para> <para>
There are two built-in server-side functions, There are two built-in server-side functions,
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/plpgsql.sgml,v 1.28 2003/11/01 01:56:29 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/plpgsql.sgml,v 1.29 2003/11/12 22:47:47 petere Exp $
--> -->
<chapter id="plpgsql"> <chapter id="plpgsql">
...@@ -195,7 +195,7 @@ END; ...@@ -195,7 +195,7 @@ END;
<para> <para>
<application>PL/pgSQL</> functions may also be declared to accept <application>PL/pgSQL</> functions may also be declared to accept
and return the <quote>polymorphic</> types and return the polymorphic types
<type>anyelement</type> and <type>anyarray</type>. The actual <type>anyelement</type> and <type>anyarray</type>. The actual
data types handled by a polymorphic function can vary from call to data types handled by a polymorphic function can vary from call to
call, as discussed in <xref linkend="extend-types-polymorphic">. call, as discussed in <xref linkend="extend-types-polymorphic">.
...@@ -255,7 +255,7 @@ end; ...@@ -255,7 +255,7 @@ end;
</para> </para>
<sect2 id="plpgsql-quote-tips"> <sect2 id="plpgsql-quote-tips">
<title>Handling of Quote Marks</title> <title>Handling of Quotation Marks</title>
<para> <para>
Since the code of a <application>PL/pgSQL</> function is specified in Since the code of a <application>PL/pgSQL</> function is specified in
...@@ -265,13 +265,13 @@ end; ...@@ -265,13 +265,13 @@ end;
rather complicated code at times, especially if you are writing a rather complicated code at times, especially if you are writing a
function that generates other functions, as in the example in <xref function that generates other functions, as in the example in <xref
linkend="plpgsql-statements-executing-dyn">. This chart may be useful linkend="plpgsql-statements-executing-dyn">. This chart may be useful
as a summary of the needed numbers of quote marks in as a summary of the needed numbers of quotation marks in
various situations. various situations.
</para> </para>
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term>1 quote mark</term> <term>1 quotation mark</term>
<listitem> <listitem>
<para> <para>
To begin and end the function body, for example: To begin and end the function body, for example:
...@@ -279,14 +279,14 @@ end; ...@@ -279,14 +279,14 @@ end;
CREATE FUNCTION foo() RETURNS integer AS '...' CREATE FUNCTION foo() RETURNS integer AS '...'
LANGUAGE plpgsql; LANGUAGE plpgsql;
</programlisting> </programlisting>
Anywhere within the function body, quote marks <emphasis>must</> Anywhere within the function body, quotation marks <emphasis>must</>
appear in pairs. appear in pairs.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>2 quote marks</term> <term>2 quotation marks</term>
<listitem> <listitem>
<para> <para>
For string literals inside the function body, for example: For string literals inside the function body, for example:
...@@ -303,10 +303,10 @@ SELECT * FROM users WHERE f_name='foobar'; ...@@ -303,10 +303,10 @@ SELECT * FROM users WHERE f_name='foobar';
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>4 quote marks</term> <term>4 quotation marks</term>
<listitem> <listitem>
<para> <para>
When you need a single quote in a string constant inside the function When you need a single quotation mark in a string constant inside the function
body, for example: body, for example:
<programlisting> <programlisting>
a_output := a_output || '' AND name LIKE ''''foobar'''' AND xyz'' a_output := a_output || '' AND name LIKE ''''foobar'''' AND xyz''
...@@ -318,10 +318,10 @@ a_output := a_output || '' AND name LIKE ''''foobar'''' AND xyz'' ...@@ -318,10 +318,10 @@ a_output := a_output || '' AND name LIKE ''''foobar'''' AND xyz''
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>6 quote marks</term> <term>6 quotation marks</term>
<listitem> <listitem>
<para> <para>
When a single quote in a string inside the function body is When a single quotation mark in a string inside the function body is
adjacent to the end of that string constant, for example: adjacent to the end of that string constant, for example:
<programlisting> <programlisting>
a_output := a_output || '' AND name LIKE ''''foobar'''''' a_output := a_output || '' AND name LIKE ''''foobar''''''
...@@ -333,11 +333,11 @@ a_output := a_output || '' AND name LIKE ''''foobar'''''' ...@@ -333,11 +333,11 @@ a_output := a_output || '' AND name LIKE ''''foobar''''''
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>10 quote marks</term> <term>10 quotation marks</term>
<listitem> <listitem>
<para> <para>
When you want two single quotes in a string constant (which When you want two single quotation marks in a string constant (which
accounts for 8 quotes) and this is adjacent to the end of that accounts for 8 quotation marks) and this is adjacent to the end of that
string constant (2 more). You will probably only need that if string constant (2 more). You will probably only need that if
you are writing a function that generates other functions. For you are writing a function that generates other functions. For
example: example:
...@@ -358,7 +358,7 @@ if v_... like ''...'' then return ''...''; end if; ...@@ -358,7 +358,7 @@ if v_... like ''...'' then return ''...''; end if;
</variablelist> </variablelist>
<para> <para>
A different approach is to escape quote marks in the function body A different approach is to escape quotation marks in the function body
with a backslash rather than by doubling them. With this method with a backslash rather than by doubling them. With this method
you'll find yourself writing things like <literal>\'\'</> instead you'll find yourself writing things like <literal>\'\'</> instead
of <literal>''''</>. Some find this easier to keep track of, some of <literal>''''</>. Some find this easier to keep track of, some
...@@ -568,7 +568,7 @@ END; ...@@ -568,7 +568,7 @@ END;
linkend="extend-types-polymorphic">). linkend="extend-types-polymorphic">).
This allows the function to access its actual return type This allows the function to access its actual return type
as shown in <xref linkend="plpgsql-declaration-type">. as shown in <xref linkend="plpgsql-declaration-type">.
<literal>$0</literal> is initialized to NULL and can be modified by <literal>$0</literal> is initialized to null and can be modified by
the function, so it can be used to hold the return value if desired, the function, so it can be used to hold the return value if desired,
though that is not required. <literal>$0</literal> can also be though that is not required. <literal>$0</literal> can also be
given an alias. For example, this function works on any data type given an alias. For example, this function works on any data type
...@@ -692,11 +692,9 @@ END; ...@@ -692,11 +692,9 @@ END;
<sect2 id="plpgsql-declaration-records"> <sect2 id="plpgsql-declaration-records">
<title>Record Types</title> <title>Record Types</title>
<para>
<synopsis> <synopsis>
<replaceable>name</replaceable> RECORD; <replaceable>name</replaceable> RECORD;
</synopsis> </synopsis>
</para>
<para> <para>
Record variables are similar to row-type variables, but they have no Record variables are similar to row-type variables, but they have no
...@@ -724,14 +722,16 @@ END; ...@@ -724,14 +722,16 @@ END;
<sect2 id="plpgsql-declaration-renaming-vars"> <sect2 id="plpgsql-declaration-renaming-vars">
<title><literal>RENAME</></title> <title><literal>RENAME</></title>
<para>
<synopsis> <synopsis>
RENAME <replaceable>oldname</replaceable> TO <replaceable>newname</replaceable>; RENAME <replaceable>oldname</replaceable> TO <replaceable>newname</replaceable>;
</synopsis> </synopsis>
Using the RENAME declaration you can change the name of a variable, <para>
record or row. This is primarily useful if NEW or OLD should be Using the <literal>RENAME</literal> declaration you can change the
referenced by another name inside a trigger procedure. See also ALIAS. name of a variable, record or row. This is primarily useful if
<literal>NEW</literal> or <literal>OLD</literal> should be
referenced by another name inside a trigger procedure. See also
<literal>ALIAS</literal>.
</para> </para>
<para> <para>
...@@ -744,12 +744,12 @@ RENAME this_var TO that_var; ...@@ -744,12 +744,12 @@ RENAME this_var TO that_var;
<note> <note>
<para> <para>
RENAME appears to be broken as of <productname>PostgreSQL</> <literal>RENAME</literal> appears to be broken as of
7.3. Fixing this is of low priority, since ALIAS covers most of <productname>PostgreSQL</> 7.3. Fixing this is of low priority,
the practical uses of RENAME. since <literal>ALIAS</literal> covers most of the practical uses
of <literal>RENAME</literal>.
</para> </para>
</note> </note>
</sect2> </sect2>
</sect1> </sect1>
...@@ -2000,7 +2000,7 @@ CLOSE curs1; ...@@ -2000,7 +2000,7 @@ CLOSE curs1;
simply assign a string to the <type>refcursor</> variable before simply assign a string to the <type>refcursor</> variable before
opening it. The string value of the <type>refcursor</> variable opening it. The string value of the <type>refcursor</> variable
will be used by <command>OPEN</> as the name of the underlying portal. will be used by <command>OPEN</> as the name of the underlying portal.
However, if the <type>refcursor</> variable is NULL, However, if the <type>refcursor</> variable is null,
<command>OPEN</> automatically generates a name that does not <command>OPEN</> automatically generates a name that does not
conflict with any existing portal, and assigns it to the conflict with any existing portal, and assigns it to the
<type>refcursor</> variable. <type>refcursor</> variable.
...@@ -2012,7 +2012,7 @@ CLOSE curs1; ...@@ -2012,7 +2012,7 @@ CLOSE curs1;
representing its name, so that the portal name is the same as representing its name, so that the portal name is the same as
the cursor variable name, unless the programmer overrides it the cursor variable name, unless the programmer overrides it
by assignment before opening the cursor. But an unbound cursor by assignment before opening the cursor. But an unbound cursor
variable defaults to an initial value of NULL, so it will receive variable defaults to the null value initially , so it will receive
an automatically-generated unique name, unless overridden. an automatically-generated unique name, unless overridden.
</para> </para>
</note> </note>
......
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/plpython.sgml,v 1.20 2003/09/12 22:17:23 tgl Exp $ --> <!-- $Header: /cvsroot/pgsql/doc/src/sgml/plpython.sgml,v 1.21 2003/11/12 22:47:47 petere Exp $ -->
<chapter id="plpython"> <chapter id="plpython">
<title>PL/Python - Python Procedural Language</title> <title>PL/Python - Python Procedural Language</title>
...@@ -17,18 +17,6 @@ ...@@ -17,18 +17,6 @@
<literal>createlang plpythonu <replaceable>dbname</></literal>. <literal>createlang plpythonu <replaceable>dbname</></literal>.
</para> </para>
<note>
<para>
As of <productname>PostgreSQL</productname> 7.4,
PL/Python is only available as an <quote>untrusted</> language
(meaning it does not offer any way of restricting what users
can do in it). It has therefore been renamed to <literal>plpythonu</>.
The trusted variant <literal>plpython</> may become available again in
future, if a new secure execution mechanism is developed by the Python
community.
</para>
</note>
<tip> <tip>
<para> <para>
If a language is installed into <literal>template1</>, all subsequently If a language is installed into <literal>template1</>, all subsequently
...@@ -36,6 +24,15 @@ ...@@ -36,6 +24,15 @@
</para> </para>
</tip> </tip>
<para>
As of <productname>PostgreSQL</productname> 7.4, PL/Python is only
available as an <quote>untrusted</> language (meaning it does not
offer any way of restricting what users can do in it). It has
therefore been renamed to <literal>plpythonu</>. The trusted
variant <literal>plpython</> may become available again in future,
if a new secure execution mechanism is developed in Python.
</para>
<note> <note>
<para> <para>
Users of source packages must specially enable the build of Users of source packages must specially enable the build of
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/pltcl.sgml,v 2.26 2003/09/08 23:02:28 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/pltcl.sgml,v 2.27 2003/11/12 22:47:47 petere Exp $
--> -->
<chapter id="pltcl"> <chapter id="pltcl">
...@@ -136,7 +136,7 @@ CREATE FUNCTION tcl_max(integer, integer) RETURNS integer AS ' ...@@ -136,7 +136,7 @@ CREATE FUNCTION tcl_max(integer, integer) RETURNS integer AS '
<para> <para>
As shown above, As shown above,
to return a NULL value from a PL/Tcl function, execute to return a null value from a PL/Tcl function, execute
<literal>return_null</literal>. This can be done whether the <literal>return_null</literal>. This can be done whether the
function is strict or not. function is strict or not.
</para> </para>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_function.sgml,v 1.53 2003/10/26 04:34:05 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_function.sgml,v 1.54 2003/11/12 22:47:47 petere Exp $
--> -->
<refentry id="SQL-CREATEFUNCTION"> <refentry id="SQL-CREATEFUNCTION">
...@@ -95,7 +95,7 @@ CREATE [ OR REPLACE ] FUNCTION <replaceable class="parameter">name</replaceable> ...@@ -95,7 +95,7 @@ CREATE [ OR REPLACE ] FUNCTION <replaceable class="parameter">name</replaceable>
<para> <para>
The data type(s) of the function's arguments (optionally The data type(s) of the function's arguments (optionally
schema-qualified), if any. The argument types may be base, complex, or schema-qualified), if any. The argument types may be base, complex, or
domain types, or copy the type of an existing column. domains, or copy the type of an existing column.
</para> </para>
<para> <para>
The type of a column is referenced by writing The type of a column is referenced by writing
...@@ -120,8 +120,8 @@ CREATE [ OR REPLACE ] FUNCTION <replaceable class="parameter">name</replaceable> ...@@ -120,8 +120,8 @@ CREATE [ OR REPLACE ] FUNCTION <replaceable class="parameter">name</replaceable>
<listitem> <listitem>
<para> <para>
The return data type (optionally schema-qualified). The return type The return data type (optionally schema-qualified). The return type
may be specified as a base, complex, or domain type, may be a base type, complex type, or a domain,
or may copy the type of an existing column. See the description or may be specified to copy the type of an existing column. See the description
under <literal>argtype</literal> above on how to reference the type under <literal>argtype</literal> above on how to reference the type
of an existing column. of an existing column.
</para> </para>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.237 2003/11/10 22:27:00 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.238 2003/11/12 22:47:47 petere Exp $
--> -->
<appendix id="release"> <appendix id="release">
...@@ -878,12 +878,12 @@ zero-row record variable (Tom)</para></listitem> ...@@ -878,12 +878,12 @@ zero-row record variable (Tom)</para></listitem>
<itemizedlist> <itemizedlist>
<listitem><para>Allow PQcmdTuples() to return row counts for MOVE and FETCH (Neil)</para></listitem> <listitem><para>Allow PQcmdTuples() to return row counts for MOVE and FETCH (Neil)</para></listitem>
<listitem><para>Add PQfreemem() for freeing memory on Win32, suggest for NOTIFY (Bruce)</para> <listitem><para>Add PQfreemem() for freeing memory on Windows, suggest for NOTIFY (Bruce)</para>
<para> <para>
Win32 requires that memory allocated in a library be freed by a Windows requires that memory allocated in a library be freed by a
function in the same library, hence free() doesn't work for freeing function in the same library, hence free() doesn't work for freeing
memory allocated by libpq. PQfreemem() is the proper way to free memory allocated by libpq. PQfreemem() is the proper way to free
libpq memory, especially on Win32, and is recommended for other libpq memory, especially on Windows, and is recommended for other
platforms as well. platforms as well.
</para> </para>
</listitem> </listitem>
...@@ -961,8 +961,8 @@ zero-row record variable (Tom)</para></listitem> ...@@ -961,8 +961,8 @@ zero-row record variable (Tom)</para></listitem>
<listitem><para>Convert administration scripts to C (Peter)</para></listitem> <listitem><para>Convert administration scripts to C (Peter)</para></listitem>
<listitem><para>Bison >= 1.85 is now required to build the PostgreSQL grammar, if building from CVS</para></listitem> <listitem><para>Bison >= 1.85 is now required to build the PostgreSQL grammar, if building from CVS</para></listitem>
<listitem><para>Merge documentation into one book (Peter)</para></listitem> <listitem><para>Merge documentation into one book (Peter)</para></listitem>
<listitem><para>Add Win32 compatibility functions (Bruce)</para></listitem> <listitem><para>Add Windows compatibility functions (Bruce)</para></listitem>
<listitem><para>Allow client interfaces to compile under MinGW/Win32 (Bruce)</para></listitem> <listitem><para>Allow client interfaces to compile under MinGW (Bruce)</para></listitem>
<listitem><para>New ereport() function for error reporting (Tom)</para></listitem> <listitem><para>New ereport() function for error reporting (Tom)</para></listitem>
<listitem><para>Support Intel Linux compiler (Peter)</para></listitem> <listitem><para>Support Intel Linux compiler (Peter)</para></listitem>
<listitem><para>Improve Linux startup scripts (Slawomir Sudnik, Darko Prenosil)</para></listitem> <listitem><para>Improve Linux startup scripts (Slawomir Sudnik, Darko Prenosil)</para></listitem>
...@@ -1794,7 +1794,7 @@ of locale?</para></listitem> ...@@ -1794,7 +1794,7 @@ of locale?</para></listitem>
<listitem><para>Fix for sending large queries over non-blocking connections (Bernhard Herzog)</para></listitem> <listitem><para>Fix for sending large queries over non-blocking connections (Bernhard Herzog)</para></listitem>
<listitem><para>Fix for libpq using timers on Win9X (David Ford)</para></listitem> <listitem><para>Fix for libpq using timers on Win9X (David Ford)</para></listitem>
<listitem><para>Allow libpq notify to handle servers with different-length identifiers (Tom)</para></listitem> <listitem><para>Allow libpq notify to handle servers with different-length identifiers (Tom)</para></listitem>
<listitem><para>Add libpq PQescapeString() and PQescapeBytea() to Win32 (Bruce)</para></listitem> <listitem><para>Add libpq PQescapeString() and PQescapeBytea() to Windows (Bruce)</para></listitem>
<listitem><para>Fix for SSL with non-blocking connections (Jack Bates)</para></listitem> <listitem><para>Fix for SSL with non-blocking connections (Jack Bates)</para></listitem>
<listitem><para>Add libpq connection timeout parameter (Denis A Ustimenko)</para></listitem> <listitem><para>Add libpq connection timeout parameter (Denis A Ustimenko)</para></listitem>
</itemizedlist> </itemizedlist>
...@@ -1846,7 +1846,7 @@ of locale?</para></listitem> ...@@ -1846,7 +1846,7 @@ of locale?</para></listitem>
<listitem><para>Always enable multibyte in compile, remove --enable-multibyte option (Tatsuo)</para></listitem> <listitem><para>Always enable multibyte in compile, remove --enable-multibyte option (Tatsuo)</para></listitem>
<listitem><para>Always enable locale in compile, remove --enable-locale option (Peter)</para></listitem> <listitem><para>Always enable locale in compile, remove --enable-locale option (Peter)</para></listitem>
<listitem><para>Fix for Win9x DLL creation (Magnus Naeslund)</para></listitem> <listitem><para>Fix for Win9x DLL creation (Magnus Naeslund)</para></listitem>
<listitem><para>Fix for link() usage by WAL code on Win32, BeOS (Jason Tishler)</para></listitem> <listitem><para>Fix for link() usage by WAL code on Windows, BeOS (Jason Tishler)</para></listitem>
<listitem><para>Add sys/types.h to c.h, remove from main files (Peter, Bruce)</para></listitem> <listitem><para>Add sys/types.h to c.h, remove from main files (Peter, Bruce)</para></listitem>
<listitem><para>Fix AIX hang on SMP machines (Tomoyuki Niijima)</para></listitem> <listitem><para>Fix AIX hang on SMP machines (Tomoyuki Niijima)</para></listitem>
<listitem><para>AIX SMP hang fix (Tomoyuki Niijima)</para></listitem> <listitem><para>AIX SMP hang fix (Tomoyuki Niijima)</para></listitem>
...@@ -1871,7 +1871,7 @@ of locale?</para></listitem> ...@@ -1871,7 +1871,7 @@ of locale?</para></listitem>
<listitem><para>New Polish FAQ (Marcin Mazurek)</para></listitem> <listitem><para>New Polish FAQ (Marcin Mazurek)</para></listitem>
<listitem><para>Add Posix semaphore support (Tom)</para></listitem> <listitem><para>Add Posix semaphore support (Tom)</para></listitem>
<listitem><para>Document need for reindex (Bruce)</para></listitem> <listitem><para>Document need for reindex (Bruce)</para></listitem>
<listitem><para>Rename some internal identifiers to simplify Win32 compile (Jan, Katherine Ward)</para></listitem> <listitem><para>Rename some internal identifiers to simplify Windows compile (Jan, Katherine Ward)</para></listitem>
<listitem><para>Add documentation on computing disk space (Bruce)</para></listitem> <listitem><para>Add documentation on computing disk space (Bruce)</para></listitem>
<listitem><para>Remove KSQO from GUC (Bruce)</para></listitem> <listitem><para>Remove KSQO from GUC (Bruce)</para></listitem>
<listitem><para>Fix memory leak in rtree (Kenneth Been)</para></listitem> <listitem><para>Fix memory leak in rtree (Kenneth Been)</para></listitem>
...@@ -2588,8 +2588,8 @@ of locale?</para></listitem> ...@@ -2588,8 +2588,8 @@ of locale?</para></listitem>
<itemizedlist> <itemizedlist>
<listitem><para>Configure, dynamic loader, and shared library fixes (Peter E)</para></listitem> <listitem><para>Configure, dynamic loader, and shared library fixes (Peter E)</para></listitem>
<listitem><para>Fixes in QNX 4 port (Bernd Tegge)</para></listitem> <listitem><para>Fixes in QNX 4 port (Bernd Tegge)</para></listitem>
<listitem><para>Fixes in Cygwin and Win32 ports (Jason Tishler, Gerhard Haring, Dmitry Yurtaev, Darko Prenosil, Mikhail Terekhov)</para></listitem> <listitem><para>Fixes in Cygwin and Windows ports (Jason Tishler, Gerhard Haring, Dmitry Yurtaev, Darko Prenosil, Mikhail Terekhov)</para></listitem>
<listitem><para>Fix for Win32 socket communication failures (Magnus, Mikhail Terekhov)</para></listitem> <listitem><para>Fix for Windows socket communication failures (Magnus, Mikhail Terekhov)</para></listitem>
<listitem><para>Hurd compile fix (Oliver Elphick)</para></listitem> <listitem><para>Hurd compile fix (Oliver Elphick)</para></listitem>
<listitem><para>BeOS fixes (Cyril Velter)</para></listitem> <listitem><para>BeOS fixes (Cyril Velter)</para></listitem>
<listitem><para>Remove configure --enable-unicode-conversion, now enabled by multibyte (Tatsuo)</para></listitem> <listitem><para>Remove configure --enable-unicode-conversion, now enabled by multibyte (Tatsuo)</para></listitem>
...@@ -3675,7 +3675,7 @@ Clean up #include in /include directory (Bruce) ...@@ -3675,7 +3675,7 @@ Clean up #include in /include directory (Bruce)
Add scripts for checking includes (Bruce) Add scripts for checking includes (Bruce)
Remove un-needed #include's from *.c files (Bruce) Remove un-needed #include's from *.c files (Bruce)
Change #include's to use &lt;&gt; and "" as appropriate (Bruce) Change #include's to use &lt;&gt; and "" as appropriate (Bruce)
Enable WIN32 compilation of libpq Enable Windows compilation of libpq
Alpha spinlock fix from Uncle George <email>gatgul@voicenet.com</email> Alpha spinlock fix from Uncle George <email>gatgul@voicenet.com</email>
Overhaul of optimizer data structures (Tom) Overhaul of optimizer data structures (Tom)
Fix to cygipc library (Yutaka Tanida) Fix to cygipc library (Yutaka Tanida)
...@@ -3688,7 +3688,7 @@ New platform-specific regression handling (Tom) ...@@ -3688,7 +3688,7 @@ New platform-specific regression handling (Tom)
Rename oid8 -&gt; oidvector and int28 -&gt; int2vector (Bruce) Rename oid8 -&gt; oidvector and int28 -&gt; int2vector (Bruce)
Included all yacc and lex files into the distribution (Peter E.) Included all yacc and lex files into the distribution (Peter E.)
Remove lextest, no longer needed (Peter E) Remove lextest, no longer needed (Peter E)
Fix for libpq and psql on Win32 (Magnus) Fix for libpq and psql on Windows (Magnus)
Internally change datetime and timespan into timestamp and interval (Thomas) Internally change datetime and timespan into timestamp and interval (Thomas)
Fix for plpgsql on BSD/OS Fix for plpgsql on BSD/OS
Add SQL_ASCII test case to the regression test (Tatsuo) Add SQL_ASCII test case to the regression test (Tatsuo)
...@@ -3772,7 +3772,7 @@ Fixes for CASE in WHERE join clauses(Tom) ...@@ -3772,7 +3772,7 @@ Fixes for CASE in WHERE join clauses(Tom)
Fix BTScan abort(Tom) Fix BTScan abort(Tom)
Repair the check for redundant UNIQUE and PRIMARY KEY indexes(Thomas) Repair the check for redundant UNIQUE and PRIMARY KEY indexes(Thomas)
Improve it so that it checks for multicolumn constraints(Thomas) Improve it so that it checks for multicolumn constraints(Thomas)
Fix for Win32 making problem with MB enabled(Hiroki Kataoka) Fix for Windows making problem with MB enabled(Hiroki Kataoka)
Allow BSD yacc and bison to compile pl code(Bruce) Allow BSD yacc and bison to compile pl code(Bruce)
Fix SET NAMES working Fix SET NAMES working
int8 fixes(Thomas) int8 fixes(Thomas)
...@@ -4230,7 +4230,7 @@ Source Tree Changes ...@@ -4230,7 +4230,7 @@ Source Tree Changes
------------------- -------------------
Improve port matching(Tom) Improve port matching(Tom)
Portability fixes for SunOS Portability fixes for SunOS
Add NT/Win32 backend port and enable dynamic loading(Magnus and Daniel Horak) Add Windows NT backend port and enable dynamic loading(Magnus and Daniel Horak)
New port to Cobalt Qube(Mips) running Linux(Tatsuo) New port to Cobalt Qube(Mips) running Linux(Tatsuo)
Port to NetBSD/m68k(Mr. Mutsuki Nakajima) Port to NetBSD/m68k(Mr. Mutsuki Nakajima)
Port to NetBSD/sun3(Mr. Mutsuki Nakajima) Port to NetBSD/sun3(Mr. Mutsuki Nakajima)
...@@ -4338,7 +4338,7 @@ Timezone fixes(Tom) ...@@ -4338,7 +4338,7 @@ Timezone fixes(Tom)
HP-UX fixes(Tom) HP-UX fixes(Tom)
Use implicit type coercion for matching DEFAULT values(Thomas) Use implicit type coercion for matching DEFAULT values(Thomas)
Add routines to help with single-byte (internal) character type(Thomas) Add routines to help with single-byte (internal) character type(Thomas)
Compilation of libpq for Win32 fixes(Magnus) Compilation of libpq for Windows fixes(Magnus)
Upgrade to PyGreSQL 2.2(D'Arcy) Upgrade to PyGreSQL 2.2(D'Arcy)
</programlisting> </programlisting>
</para> </para>
...@@ -4523,7 +4523,7 @@ New contrib/lo code for large object orphan removal(Peter) ...@@ -4523,7 +4523,7 @@ New contrib/lo code for large object orphan removal(Peter)
New psql command "SET CLIENT_ENCODING TO 'encoding'" for multibytes New psql command "SET CLIENT_ENCODING TO 'encoding'" for multibytes
feature, see /doc/README.mb(Tatsuo) feature, see /doc/README.mb(Tatsuo)
/contrib/noupdate code to revoke update permission on a column /contrib/noupdate code to revoke update permission on a column
libpq can now be compiled on win32(Magnus) libpq can now be compiled on Windows(Magnus)
Add PQsetdbLogin() in libpq Add PQsetdbLogin() in libpq
New 8-byte integer type, checked by configure for OS support(Thomas) New 8-byte integer type, checked by configure for OS support(Thomas)
Better support for quoted table/column names(Thomas) Better support for quoted table/column names(Thomas)
...@@ -4586,7 +4586,7 @@ New setval() command to set sequence value(Massimo) ...@@ -4586,7 +4586,7 @@ New setval() command to set sequence value(Massimo)
Auto-remove unix socket file on start-up if no postmaster running(Massimo) Auto-remove unix socket file on start-up if no postmaster running(Massimo)
Conditional trace package(Massimo) Conditional trace package(Massimo)
New UNLISTEN command(Massimo) New UNLISTEN command(Massimo)
psql and libpq now compile under win32 using win32.mak(Magnus) psql and libpq now compile under Windows using win32.mak(Magnus)
Lo_read no longer stores trailing NULL(Bruce) Lo_read no longer stores trailing NULL(Bruce)
Identifiers are now truncated to 31 characters internally(Bruce) Identifiers are now truncated to 31 characters internally(Bruce)
Createuser options now availble on the command line Createuser options now availble on the command line
...@@ -5551,7 +5551,7 @@ new OS-specific template files(Marc) ...@@ -5551,7 +5551,7 @@ new OS-specific template files(Marc)
no more need to edit Makefile.global(Marc) no more need to edit Makefile.global(Marc)
re-arrange include files(Marc) re-arrange include files(Marc)
nextstep patches (Gregor Hoffleit) nextstep patches (Gregor Hoffleit)
removed WIN32-specific code(Bruce) removed Windows-specific code(Bruce)
removed postmaster -e option, now only postgres -e option (Bruce) removed postmaster -e option, now only postgres -e option (Bruce)
merge duplicate library code in front/backends(Martin) merge duplicate library code in front/backends(Martin)
now works with eBones, international Kerberos(Jun) now works with eBones, international Kerberos(Jun)
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/typeconv.sgml,v 1.37 2003/11/04 09:55:39 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/typeconv.sgml,v 1.38 2003/11/12 22:47:47 petere Exp $
--> -->
<chapter Id="typeconv"> <chapter Id="typeconv">
...@@ -289,7 +289,7 @@ candidate remains, use it; else continue to the next step. ...@@ -289,7 +289,7 @@ candidate remains, use it; else continue to the next step.
<step performance="required"> <step performance="required">
<para> <para>
Run through all candidates and keep those with the most exact matches Run through all candidates and keep those with the most exact matches
on input types. (Domain types are considered the same as their base type on input types. (Domains are considered the same as their base type
for this purpose.) Keep all candidates if none have any exact matches. for this purpose.) Keep all candidates if none have any exact matches.
If only one candidate remains, use it; else continue to the next step. If only one candidate remains, use it; else continue to the next step.
</para> </para>
...@@ -542,7 +542,7 @@ candidate remains, use it; else continue to the next step. ...@@ -542,7 +542,7 @@ candidate remains, use it; else continue to the next step.
<step performance="required"> <step performance="required">
<para> <para>
Run through all candidates and keep those with the most exact matches Run through all candidates and keep those with the most exact matches
on input types. (Domain types are considered the same as their base type on input types. (Domains are considered the same as their base type
for this purpose.) Keep all candidates if none have any exact matches. for this purpose.) Keep all candidates if none have any exact matches.
If only one candidate remains, use it; else continue to the next step. If only one candidate remains, use it; else continue to the next step.
</para> </para>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/xaggr.sgml,v 1.22 2003/08/31 17:32:20 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/xaggr.sgml,v 1.23 2003/11/12 22:47:47 petere Exp $
--> -->
<sect1 id="xaggr"> <sect1 id="xaggr">
...@@ -140,16 +140,20 @@ CREATE AGGREGATE array_accum ( ...@@ -140,16 +140,20 @@ CREATE AGGREGATE array_accum (
<programlisting> <programlisting>
SELECT attrelid::regclass, array_accum(attname) SELECT attrelid::regclass, array_accum(attname)
FROM pg_attribute WHERE attnum > 0 FROM pg_attribute
AND attrelid = 'pg_user'::regclass GROUP BY attrelid; WHERE attnum > 0 AND attrelid = 'pg_user'::regclass
GROUP BY attrelid;
attrelid | array_accum attrelid | array_accum
----------+----------------------------------------------------------------------------- ----------+-----------------------------------------------------------------------------
pg_user | {usename,usesysid,usecreatedb,usesuper,usecatupd,passwd,valuntil,useconfig} pg_user | {usename,usesysid,usecreatedb,usesuper,usecatupd,passwd,valuntil,useconfig}
(1 row) (1 row)
SELECT attrelid::regclass, array_accum(atttypid) SELECT attrelid::regclass, array_accum(atttypid)
FROM pg_attribute WHERE attnum > 0 FROM pg_attribute
AND attrelid = 'pg_user'::regclass GROUP BY attrelid; WHERE attnum > 0 AND attrelid = 'pg_user'::regclass
GROUP BY attrelid;
attrelid | array_accum attrelid | array_accum
----------+------------------------------ ----------+------------------------------
pg_user | {19,23,16,16,16,25,702,1009} pg_user | {19,23,16,16,16,25,702,1009}
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.77 2003/11/01 01:56:29 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.78 2003/11/12 22:47:47 petere Exp $
--> -->
<sect1 id="xfunc"> <sect1 id="xfunc">
...@@ -392,9 +392,9 @@ SELECT name(emp) AS youngster ...@@ -392,9 +392,9 @@ SELECT name(emp) AS youngster
result of the first function to it: result of the first function to it:
<screen> <screen>
CREATE FUNCTION getname(emp) RETURNS text AS CREATE FUNCTION getname(emp) RETURNS text AS '
'SELECT $1.name;' SELECT $1.name;
LANGUAGE SQL; ' LANGUAGE SQL;
SELECT getname(new_emp()); SELECT getname(new_emp());
getname getname
...@@ -538,12 +538,12 @@ SELECT name, listchildren(name) FROM nodes; ...@@ -538,12 +538,12 @@ SELECT name, listchildren(name) FROM nodes;
<para> <para>
<acronym>SQL</acronym> functions may be declared to accept and <acronym>SQL</acronym> functions may be declared to accept and
return the <quote>polymorphic</> types return the polymorphic types <type>anyelement</type> and
<type>anyelement</type> and <type>anyarray</type>. <type>anyarray</type>. See <xref
See <xref linkend="extend-types-polymorphic"> for a more detailed explanation linkend="extend-types-polymorphic"> for a more detailed
of polymorphic functions. Here is a polymorphic function explanation of polymorphic functions. Here is a polymorphic
<function>make_array</function> that builds up an array from two function <function>make_array</function> that builds up an array
arbitrary data type elements: from two arbitrary data type elements:
<screen> <screen>
CREATE FUNCTION make_array(anyelement, anyelement) RETURNS anyarray AS ' CREATE FUNCTION make_array(anyelement, anyelement) RETURNS anyarray AS '
SELECT ARRAY[$1, $2]; SELECT ARRAY[$1, $2];
...@@ -567,7 +567,7 @@ SELECT make_array(1, 2) AS intarray, make_array('a'::text, 'b') AS textarray; ...@@ -567,7 +567,7 @@ SELECT make_array(1, 2) AS intarray, make_array('a'::text, 'b') AS textarray;
Without the typecast, you will get errors like this: Without the typecast, you will get errors like this:
<screen> <screen>
<computeroutput> <computeroutput>
ERROR: could not determine ANYARRAY/ANYELEMENT type because input is UNKNOWN ERROR: could not determine "anyarray"/"anyelement" type because input has type "unknown"
</computeroutput> </computeroutput>
</screen> </screen>
</para> </para>
...@@ -576,7 +576,7 @@ ERROR: could not determine ANYARRAY/ANYELEMENT type because input is UNKNOWN ...@@ -576,7 +576,7 @@ ERROR: could not determine ANYARRAY/ANYELEMENT type because input is UNKNOWN
It is permitted to have polymorphic arguments with a deterministic It is permitted to have polymorphic arguments with a deterministic
return type, but the converse is not. For example: return type, but the converse is not. For example:
<screen> <screen>
CREATE FUNCTION is_greater(anyelement, anyelement) RETURNS bool AS ' CREATE FUNCTION is_greater(anyelement, anyelement) RETURNS boolean AS '
SELECT $1 > $2; SELECT $1 > $2;
' LANGUAGE SQL; ' LANGUAGE SQL;
...@@ -589,8 +589,8 @@ SELECT is_greater(1, 2); ...@@ -589,8 +589,8 @@ SELECT is_greater(1, 2);
CREATE FUNCTION invalid_func() RETURNS anyelement AS ' CREATE FUNCTION invalid_func() RETURNS anyelement AS '
SELECT 1; SELECT 1;
' LANGUAGE SQL; ' LANGUAGE SQL;
ERROR: cannot determine result datatype ERROR: cannot determine result data type
DETAIL: A function returning ANYARRAY or ANYELEMENT must have at least one argument of either type. DETAIL: A function returning "anyarray" or "anyelement" must have at least one argument of either type.
</screen> </screen>
</para> </para>
</sect2> </sect2>
...@@ -758,15 +758,13 @@ CREATE FUNCTION square_root(double precision) RETURNS double precision ...@@ -758,15 +758,13 @@ CREATE FUNCTION square_root(double precision) RETURNS double precision
that fails as well, the load will fail. that fails as well, the load will fail.
</para> </para>
<note>
<para> <para>
The user ID the <productname>PostgreSQL</productname> server runs The user ID the <productname>PostgreSQL</productname> server runs
as must be able to traverse the path to the file you intend to as must be able to traverse the path to the file you intend to
load. Making the file or a higher-level directory not readable load. Making the file or a higher-level directory not readable
and/or not executable by the <systemitem>postgres</systemitem> user is a and/or not executable by the <systemitem>postgres</systemitem>
common mistake. user is a common mistake.
</para> </para>
</note>
<para> <para>
In any case, the file name that is given in the In any case, the file name that is given in the
...@@ -785,16 +783,14 @@ CREATE FUNCTION square_root(double precision) RETURNS double precision ...@@ -785,16 +783,14 @@ CREATE FUNCTION square_root(double precision) RETURNS double precision
</para> </para>
</note> </note>
<note>
<para> <para>
After it is used for the first time, a dynamically loaded object After it is used for the first time, a dynamically loaded object
file is retained in memory. Future calls in the same session to the file is retained in memory. Future calls in the same session to
function(s) in that file will only incur the small overhead of a symbol the function(s) in that file will only incur the small overhead of
table lookup. If you need to force a reload of an object file, for a symbol table lookup. If you need to force a reload of an object
example after recompiling it, use the <command>LOAD</> command or file, for example after recompiling it, use the <command>LOAD</>
begin a fresh session. command or begin a fresh session.
</para> </para>
</note>
<para> <para>
It is recommended to locate shared libraries either relative to It is recommended to locate shared libraries either relative to
...@@ -805,17 +801,15 @@ CREATE FUNCTION square_root(double precision) RETURNS double precision ...@@ -805,17 +801,15 @@ CREATE FUNCTION square_root(double precision) RETURNS double precision
command <literal>pg_config --pkglibdir</literal>. command <literal>pg_config --pkglibdir</literal>.
</para> </para>
<note>
<para> <para>
Before <productname>PostgreSQL</productname> release 7.2, only exact Before <productname>PostgreSQL</productname> release 7.2, only
absolute paths to object files could be specified in <command>CREATE exact absolute paths to object files could be specified in
FUNCTION</>. This approach is now deprecated since it makes the <command>CREATE FUNCTION</>. This approach is now deprecated
function definition unnecessarily unportable. It's best to specify since it makes the function definition unnecessarily unportable.
just the shared library name with no path nor extension, and let It's best to specify just the shared library name with no path nor
the search mechanism provide that information instead. extension, and let the search mechanism provide that information
instead.
</para> </para>
</note>
</sect2> </sect2>
<sect2 id="xfunc-c-basetype"> <sect2 id="xfunc-c-basetype">
...@@ -1685,8 +1679,7 @@ c_overpaid(PG_FUNCTION_ARGS) ...@@ -1685,8 +1679,7 @@ c_overpaid(PG_FUNCTION_ARGS)
<function>c_overpaid</function> in SQL: <function>c_overpaid</function> in SQL:
<programlisting> <programlisting>
CREATE FUNCTION c_overpaid(emp, integer) CREATE FUNCTION c_overpaid(emp, integer) RETURNS boolean
RETURNS boolean
AS '<replaceable>DIRECTORY</replaceable>/funcs', 'c_overpaid' AS '<replaceable>DIRECTORY</replaceable>/funcs', 'c_overpaid'
LANGUAGE C; LANGUAGE C;
</programlisting> </programlisting>
...@@ -2111,7 +2104,7 @@ CREATE OR REPLACE FUNCTION testpassbyval(integer, integer) RETURNS SETOF __testp ...@@ -2111,7 +2104,7 @@ CREATE OR REPLACE FUNCTION testpassbyval(integer, integer) RETURNS SETOF __testp
<para> <para>
C-language functions may be declared to accept and C-language functions may be declared to accept and
return the <quote>polymorphic</> types return the polymorphic types
<type>anyelement</type> and <type>anyarray</type>. <type>anyelement</type> and <type>anyarray</type>.
See <xref linkend="extend-types-polymorphic"> for a more detailed explanation See <xref linkend="extend-types-polymorphic"> for a more detailed explanation
of polymorphic functions. When function arguments or return types of polymorphic functions. When function arguments or return types
...@@ -2178,14 +2171,13 @@ make_array(PG_FUNCTION_ARGS) ...@@ -2178,14 +2171,13 @@ make_array(PG_FUNCTION_ARGS)
<function>make_array</function> in SQL: <function>make_array</function> in SQL:
<programlisting> <programlisting>
CREATE FUNCTION make_array(anyelement) CREATE FUNCTION make_array(anyelement) RETURNS anyarray
RETURNS anyarray
AS '<replaceable>DIRECTORY</replaceable>/funcs', 'make_array' AS '<replaceable>DIRECTORY</replaceable>/funcs', 'make_array'
LANGUAGE 'C' STRICT; LANGUAGE C STRICT;
</programlisting> </programlisting>
Note the use of STRICT; this is essential since the code is not Note the use of <literal>STRICT</literal>; this is essential
bothering to test for a NULL input. since the code is not bothering to test for a null input.
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment