1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Add optional "validator" function to languages that can validate the

function body (and other properties) as a function in the language
is created.  This generalizes ad hoc code that already existed for
the built-in languages.

The validation now happens after the pg_proc tuple of the new function
is created, so it is possible to define recursive SQL functions.

Add some regression test cases that cover bogus function definition
attempts.
This commit is contained in:
Peter Eisentraut
2002-05-22 17:21:02 +00:00
parent df9c8e1a39
commit d60f10b0e7
18 changed files with 339 additions and 102 deletions

View File

@ -1,5 +1,5 @@
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_language.sgml,v 1.23 2002/05/18 15:44:47 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_language.sgml,v 1.24 2002/05/22 17:20:58 petere Exp $
PostgreSQL documentation
-->
@ -17,7 +17,7 @@ PostgreSQL documentation
<refsynopsisdiv>
<synopsis>
CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="parameter">langname</replaceable>
HANDLER <replaceable class="parameter">call_handler</replaceable>
HANDLER <replaceable class="parameter">call_handler</replaceable> [ VALIDATOR <replaceable>valfunction</replaceable> ]
</synopsis>
</refsynopsisdiv>
@ -113,6 +113,32 @@ CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="parameter">langna
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>VALIDATOR</literal> <replaceable class="parameter">valfunction</replaceable></term>
<listitem>
<para>
<replaceable class="parameter">valfunction</replaceable> is the
name of a previously registered function that will be called
when a new function in the language is created, to validate the
new function. The validator function must take one argument of
type <type>oid</type>, which will be the OID of the
to-be-created function, and can have any return type. If no
validator function is specified, then a new function will not
be checked when it is created.
</para>
<para>
A validator function would typically inspect the function body
for syntactical correctness, but it can also look at other
properties of the function, for example if the language cannot
handle certain argument types. To signal an error, the
validator function should use the <function>elog()</function>
function. The return value of the function is ignored.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

View File

@ -1,5 +1,5 @@
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.137 2002/05/18 13:47:59 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.138 2002/05/22 17:20:58 petere Exp $
-->
<appendix id="release">
@ -24,6 +24,8 @@ CDATA means the content is "SGML-free", so you can write without
worries about funny characters.
-->
<literallayout><![CDATA[
Recursive SQL functions can be defined
User-defined procedural languages can register a validator function to check new functions as they are created
Functions can be executed with the privileges of the owner
Syntax of CREATE FUNCTION has been extended to resemble SQL99
Effects of SET within a transaction block now roll back if transaction aborts
@ -72,7 +74,7 @@ Database and user-specific session defaults for run-time configuration variables
<title>Changes</title>
<para>
<programlisting>
<literallayout>
Ensure that sequence counters do not go backwards after a crash (Tom)
Fix pgaccess kanji-coversion key binding (Tatsuo)
Optimizer improvements (Tom)
@ -90,7 +92,7 @@ contrib/tsearch dictionary improvements, see README.tsearch for
an additional installation step (Thomas T. Thai, Teodor Sigaev)
Fix for array subscripts handling (Tom)
Allow EXECUTE of "CREATE TABLE AS ... SELECT" in PL/PgSQL (Tom)
</programlisting>
</literallayout>
</para>
</sect2>
</sect1>