Commit b1949577 authored by Peter Eisentraut's avatar Peter Eisentraut

doc: Update uses of the word "procedure"

Historically, the term procedure was used as a synonym for function in
Postgres/PostgreSQL.  Now we have procedures as separate objects from
functions, so we need to clean up the documentation to not mix those
terms.

In particular, mentions of "trigger procedures" are changed to "trigger
functions", and access method "support procedures" are changed to
"support functions".  (The latter already used FUNCTION in the SQL
syntax anyway.)  Also, the terminology in the SPI chapter has been
cleaned up.

A few tests, examples, and code comments are also adjusted to be
consistent with documentation changes, but not everything.
Reported-by: default avatarPeter Geoghegan <pg@bowt.ie>
Reviewed-by: default avatarJonathan S. Katz <jonathan.katz@excoventures.com>
parent af63926c
...@@ -537,7 +537,7 @@ typedef struct BrinOpcInfo ...@@ -537,7 +537,7 @@ typedef struct BrinOpcInfo
} BrinOpcInfo; } BrinOpcInfo;
</programlisting> </programlisting>
<structname>BrinOpcInfo</structname>.<structfield>oi_opaque</structfield> can be used by the <structname>BrinOpcInfo</structname>.<structfield>oi_opaque</structfield> can be used by the
operator class routines to pass information between support procedures operator class routines to pass information between support functions
during an index scan. during an index scan.
</para> </para>
</listitem> </listitem>
...@@ -587,27 +587,27 @@ typedef struct BrinOpcInfo ...@@ -587,27 +587,27 @@ typedef struct BrinOpcInfo
defined by the user for other data types using equivalent definitions, defined by the user for other data types using equivalent definitions,
without having to write any source code; appropriate catalog entries being without having to write any source code; appropriate catalog entries being
declared is enough. Note that assumptions about the semantics of operator declared is enough. Note that assumptions about the semantics of operator
strategies are embedded in the support procedures' source code. strategies are embedded in the support functions' source code.
</para> </para>
<para> <para>
Operator classes that implement completely different semantics are also Operator classes that implement completely different semantics are also
possible, provided implementations of the four main support procedures possible, provided implementations of the four main support functions
described above are written. Note that backwards compatibility across major described above are written. Note that backwards compatibility across major
releases is not guaranteed: for example, additional support procedures might releases is not guaranteed: for example, additional support functions might
be required in later releases. be required in later releases.
</para> </para>
<para> <para>
To write an operator class for a data type that implements a totally To write an operator class for a data type that implements a totally
ordered set, it is possible to use the minmax support procedures ordered set, it is possible to use the minmax support functions
alongside the corresponding operators, as shown in alongside the corresponding operators, as shown in
<xref linkend="brin-extensibility-minmax-table"/>. <xref linkend="brin-extensibility-minmax-table"/>.
All operator class members (procedures and operators) are mandatory. All operator class members (functions and operators) are mandatory.
</para> </para>
<table id="brin-extensibility-minmax-table"> <table id="brin-extensibility-minmax-table">
<title>Procedure and Support Numbers for Minmax Operator Classes</title> <title>Function and Support Numbers for Minmax Operator Classes</title>
<tgroup cols="2"> <tgroup cols="2">
<thead> <thead>
<row> <row>
...@@ -617,19 +617,19 @@ typedef struct BrinOpcInfo ...@@ -617,19 +617,19 @@ typedef struct BrinOpcInfo
</thead> </thead>
<tbody> <tbody>
<row> <row>
<entry>Support Procedure 1</entry> <entry>Support Function 1</entry>
<entry>internal function <function>brin_minmax_opcinfo()</function></entry> <entry>internal function <function>brin_minmax_opcinfo()</function></entry>
</row> </row>
<row> <row>
<entry>Support Procedure 2</entry> <entry>Support Function 2</entry>
<entry>internal function <function>brin_minmax_add_value()</function></entry> <entry>internal function <function>brin_minmax_add_value()</function></entry>
</row> </row>
<row> <row>
<entry>Support Procedure 3</entry> <entry>Support Function 3</entry>
<entry>internal function <function>brin_minmax_consistent()</function></entry> <entry>internal function <function>brin_minmax_consistent()</function></entry>
</row> </row>
<row> <row>
<entry>Support Procedure 4</entry> <entry>Support Function 4</entry>
<entry>internal function <function>brin_minmax_union()</function></entry> <entry>internal function <function>brin_minmax_union()</function></entry>
</row> </row>
<row> <row>
...@@ -659,7 +659,7 @@ typedef struct BrinOpcInfo ...@@ -659,7 +659,7 @@ typedef struct BrinOpcInfo
<para> <para>
To write an operator class for a complex data type which has values To write an operator class for a complex data type which has values
included within another type, it's possible to use the inclusion support included within another type, it's possible to use the inclusion support
procedures alongside the corresponding operators, as shown functions alongside the corresponding operators, as shown
in <xref linkend="brin-extensibility-inclusion-table"/>. It requires in <xref linkend="brin-extensibility-inclusion-table"/>. It requires
only a single additional function, which can be written in any language. only a single additional function, which can be written in any language.
More functions can be defined for additional functionality. All operators More functions can be defined for additional functionality. All operators
...@@ -668,7 +668,7 @@ typedef struct BrinOpcInfo ...@@ -668,7 +668,7 @@ typedef struct BrinOpcInfo
</para> </para>
<table id="brin-extensibility-inclusion-table"> <table id="brin-extensibility-inclusion-table">
<title>Procedure and Support Numbers for Inclusion Operator Classes</title> <title>Function and Support Numbers for Inclusion Operator Classes</title>
<tgroup cols="3"> <tgroup cols="3">
<thead> <thead>
<row> <row>
...@@ -679,42 +679,42 @@ typedef struct BrinOpcInfo ...@@ -679,42 +679,42 @@ typedef struct BrinOpcInfo
</thead> </thead>
<tbody> <tbody>
<row> <row>
<entry>Support Procedure 1</entry> <entry>Support Function 1</entry>
<entry>internal function <function>brin_inclusion_opcinfo()</function></entry> <entry>internal function <function>brin_inclusion_opcinfo()</function></entry>
<entry></entry> <entry></entry>
</row> </row>
<row> <row>
<entry>Support Procedure 2</entry> <entry>Support Function 2</entry>
<entry>internal function <function>brin_inclusion_add_value()</function></entry> <entry>internal function <function>brin_inclusion_add_value()</function></entry>
<entry></entry> <entry></entry>
</row> </row>
<row> <row>
<entry>Support Procedure 3</entry> <entry>Support Function 3</entry>
<entry>internal function <function>brin_inclusion_consistent()</function></entry> <entry>internal function <function>brin_inclusion_consistent()</function></entry>
<entry></entry> <entry></entry>
</row> </row>
<row> <row>
<entry>Support Procedure 4</entry> <entry>Support Function 4</entry>
<entry>internal function <function>brin_inclusion_union()</function></entry> <entry>internal function <function>brin_inclusion_union()</function></entry>
<entry></entry> <entry></entry>
</row> </row>
<row> <row>
<entry>Support Procedure 11</entry> <entry>Support Function 11</entry>
<entry>function to merge two elements</entry> <entry>function to merge two elements</entry>
<entry></entry> <entry></entry>
</row> </row>
<row> <row>
<entry>Support Procedure 12</entry> <entry>Support Function 12</entry>
<entry>optional function to check whether two elements are mergeable</entry> <entry>optional function to check whether two elements are mergeable</entry>
<entry></entry> <entry></entry>
</row> </row>
<row> <row>
<entry>Support Procedure 13</entry> <entry>Support Function 13</entry>
<entry>optional function to check if an element is contained within another</entry> <entry>optional function to check if an element is contained within another</entry>
<entry></entry> <entry></entry>
</row> </row>
<row> <row>
<entry>Support Procedure 14</entry> <entry>Support Function 14</entry>
<entry>optional function to check whether an element is empty</entry> <entry>optional function to check whether an element is empty</entry>
<entry></entry> <entry></entry>
</row> </row>
...@@ -803,7 +803,7 @@ typedef struct BrinOpcInfo ...@@ -803,7 +803,7 @@ typedef struct BrinOpcInfo
</table> </table>
<para> <para>
Support procedure numbers 1-10 are reserved for the BRIN internal Support function numbers 1-10 are reserved for the BRIN internal
functions, so the SQL level functions start with number 11. Support functions, so the SQL level functions start with number 11. Support
function number 11 is the main function required to build the index. function number 11 is the main function required to build the index.
It should accept two arguments with the same data type as the operator class, It should accept two arguments with the same data type as the operator class,
...@@ -814,11 +814,11 @@ typedef struct BrinOpcInfo ...@@ -814,11 +814,11 @@ typedef struct BrinOpcInfo
</para> </para>
<para> <para>
Support procedure numbers 12 and 14 are provided to support Support function numbers 12 and 14 are provided to support
irregularities of built-in data types. Procedure number 12 irregularities of built-in data types. Function number 12
is used to support network addresses from different families which is used to support network addresses from different families which
are not mergeable. Procedure number 14 is used to support are not mergeable. Function number 14 is used to support
empty ranges. Procedure number 13 is an optional but empty ranges. Function number 13 is an optional but
recommended one, which allows the new value to be checked before recommended one, which allows the new value to be checked before
it is passed to the union function. As the BRIN framework can shortcut it is passed to the union function. As the BRIN framework can shortcut
some operations when the union is not changed, using this some operations when the union is not changed, using this
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
<row> <row>
<entry><link linkend="catalog-pg-amproc"><structname>pg_amproc</structname></link></entry> <entry><link linkend="catalog-pg-amproc"><structname>pg_amproc</structname></link></entry>
<entry>access method support procedures</entry> <entry>access method support functions</entry>
</row> </row>
<row> <row>
...@@ -814,8 +814,8 @@ ...@@ -814,8 +814,8 @@
<para> <para>
The catalog <structname>pg_amproc</structname> stores information about The catalog <structname>pg_amproc</structname> stores information about
support procedures associated with access method operator families. There support functions associated with access method operator families. There
is one row for each support procedure belonging to an operator family. is one row for each support function belonging to an operator family.
</para> </para>
<table> <table>
...@@ -864,14 +864,14 @@ ...@@ -864,14 +864,14 @@
<entry><structfield>amprocnum</structfield></entry> <entry><structfield>amprocnum</structfield></entry>
<entry><type>int2</type></entry> <entry><type>int2</type></entry>
<entry></entry> <entry></entry>
<entry>Support procedure number</entry> <entry>Support function number</entry>
</row> </row>
<row> <row>
<entry><structfield>amproc</structfield></entry> <entry><structfield>amproc</structfield></entry>
<entry><type>regproc</type></entry> <entry><type>regproc</type></entry>
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry> <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
<entry>OID of the procedure</entry> <entry>OID of the function</entry>
</row> </row>
</tbody> </tbody>
...@@ -882,9 +882,9 @@ ...@@ -882,9 +882,9 @@
The usual interpretation of the The usual interpretation of the
<structfield>amproclefttype</structfield> and <structfield>amprocrighttype</structfield> fields <structfield>amproclefttype</structfield> and <structfield>amprocrighttype</structfield> fields
is that they identify the left and right input types of the operator(s) is that they identify the left and right input types of the operator(s)
that a particular support procedure supports. For some access methods that a particular support function supports. For some access methods
these match the input data type(s) of the support procedure itself, for these match the input data type(s) of the support function itself, for
others not. There is a notion of <quote>default</quote> support procedures for others not. There is a notion of <quote>default</quote> support functions for
an index, which are those with <structfield>amproclefttype</structfield> and an index, which are those with <structfield>amproclefttype</structfield> and
<structfield>amprocrighttype</structfield> both equal to the index operator class's <structfield>amprocrighttype</structfield> both equal to the index operator class's
<structfield>opcintype</structfield>. <structfield>opcintype</structfield>.
...@@ -2471,7 +2471,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l ...@@ -2471,7 +2471,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
<para> <para>
The catalog <structname>pg_conversion</structname> describes The catalog <structname>pg_conversion</structname> describes
encoding conversion procedures. See <xref linkend="sql-createconversion"/> encoding conversion functions. See <xref linkend="sql-createconversion"/>
for more information. for more information.
</para> </para>
...@@ -2537,7 +2537,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l ...@@ -2537,7 +2537,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
<entry><structfield>conproc</structfield></entry> <entry><structfield>conproc</structfield></entry>
<entry><type>regproc</type></entry> <entry><type>regproc</type></entry>
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry> <entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
<entry>Conversion procedure</entry> <entry>Conversion function</entry>
</row> </row>
<row> <row>
......
...@@ -1053,9 +1053,9 @@ CREATE EVENT TRIGGER noddl ON ddl_command_start ...@@ -1053,9 +1053,9 @@ CREATE EVENT TRIGGER noddl ON ddl_command_start
<screen> <screen>
=# \dy =# \dy
List of event triggers List of event triggers
Name | Event | Owner | Enabled | Procedure | Tags Name | Event | Owner | Enabled | Function | Tags
-------+-------------------+-------+---------+-----------+------ -------+-------------------+-------+---------+----------+------
noddl | ddl_command_start | dim | enabled | noddl | noddl | ddl_command_start | dim | enabled | noddl |
(1 row) (1 row)
=# CREATE TABLE foo(id serial); =# CREATE TABLE foo(id serial);
......
...@@ -12360,7 +12360,7 @@ SELECT setval('foo', 42, false); <lineannotation>Next <function>nextval</func ...@@ -12360,7 +12360,7 @@ SELECT setval('foo', 42, false); <lineannotation>Next <function>nextval</func
<tip> <tip>
<para> <para>
If your needs go beyond the capabilities of these conditional If your needs go beyond the capabilities of these conditional
expressions, you might want to consider writing a stored procedure expressions, you might want to consider writing a server-side function
in a more expressive programming language. in a more expressive programming language.
</para> </para>
</tip> </tip>
......
...@@ -119,7 +119,7 @@ plsample_call_handler(PG_FUNCTION_ARGS) ...@@ -119,7 +119,7 @@ plsample_call_handler(PG_FUNCTION_ARGS)
if (CALLED_AS_TRIGGER(fcinfo)) if (CALLED_AS_TRIGGER(fcinfo))
{ {
/* /*
* Called as a trigger procedure * Called as a trigger function
*/ */
TriggerData *trigdata = (TriggerData *) fcinfo-&gt;context; TriggerData *trigdata = (TriggerData *) fcinfo-&gt;context;
......
...@@ -1337,7 +1337,7 @@ CREATE TRIGGER test_valid_id_trig ...@@ -1337,7 +1337,7 @@ CREATE TRIGGER test_valid_id_trig
</para> </para>
<para> <para>
The return value of the trigger procedure is ignored. The return value of the trigger function is ignored.
</para> </para>
<para> <para>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<itemizedlist> <itemizedlist>
<listitem> <listitem>
<para> <para>
can be used to create functions and trigger procedures, can be used to create functions and triggers,
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
...@@ -305,7 +305,7 @@ $$ LANGUAGE plpgsql; ...@@ -305,7 +305,7 @@ $$ LANGUAGE plpgsql;
for transaction for transaction
control. <application>PL/pgSQL</application>'s <command>BEGIN</command>/<command>END</command> control. <application>PL/pgSQL</application>'s <command>BEGIN</command>/<command>END</command>
are only for grouping; they do not start or end a transaction. are only for grouping; they do not start or end a transaction.
Functions and trigger procedures are always executed within a transaction Functions are always executed within a transaction
established by an outer query &mdash; they cannot start or commit that established by an outer query &mdash; they cannot start or commit that
transaction, since there would be no context for them to execute in. transaction, since there would be no context for them to execute in.
However, a block containing an <literal>EXCEPTION</literal> clause effectively However, a block containing an <literal>EXCEPTION</literal> clause effectively
...@@ -579,7 +579,7 @@ $$ LANGUAGE plpgsql; ...@@ -579,7 +579,7 @@ $$ LANGUAGE plpgsql;
function parameters. The main practical use for this is to assign function parameters. The main practical use for this is to assign
a different name for variables with predetermined names, such as a different name for variables with predetermined names, such as
<varname>NEW</varname> or <varname>OLD</varname> within <varname>NEW</varname> or <varname>OLD</varname> within
a trigger procedure. a trigger function.
</para> </para>
<para> <para>
...@@ -3796,7 +3796,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl ...@@ -3796,7 +3796,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
</sect1> </sect1>
<sect1 id="plpgsql-trigger"> <sect1 id="plpgsql-trigger">
<title>Trigger Procedures</title> <title>Trigger Functions</title>
<indexterm zone="plpgsql-trigger"> <indexterm zone="plpgsql-trigger">
<primary>trigger</primary> <primary>trigger</primary>
...@@ -3805,8 +3805,8 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl ...@@ -3805,8 +3805,8 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
<para> <para>
<application>PL/pgSQL</application> can be used to define trigger <application>PL/pgSQL</application> can be used to define trigger
procedures on data changes or database events. functions on data changes or database events.
A trigger procedure is created with the <command>CREATE FUNCTION</command> A trigger function is created with the <command>CREATE FUNCTION</command>
command, declaring it as a function with no arguments and a return type of command, declaring it as a function with no arguments and a return type of
<type>trigger</type> (for data change triggers) or <type>trigger</type> (for data change triggers) or
<type>event_trigger</type> (for database event triggers). <type>event_trigger</type> (for database event triggers).
...@@ -3946,7 +3946,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl ...@@ -3946,7 +3946,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
<listitem> <listitem>
<para> <para>
Data type <type>integer</type>; the number of arguments given to the trigger Data type <type>integer</type>; the number of arguments given to the trigger
procedure in the <command>CREATE TRIGGER</command> statement. function in the <command>CREATE TRIGGER</command> statement.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -4025,11 +4025,11 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl ...@@ -4025,11 +4025,11 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
<para> <para>
<xref linkend="plpgsql-trigger-example"/> shows an example of a <xref linkend="plpgsql-trigger-example"/> shows an example of a
trigger procedure in <application>PL/pgSQL</application>. trigger function in <application>PL/pgSQL</application>.
</para> </para>
<example id="plpgsql-trigger-example"> <example id="plpgsql-trigger-example">
<title>A <application>PL/pgSQL</application> Trigger Procedure</title> <title>A <application>PL/pgSQL</application> Trigger Function</title>
<para> <para>
This example trigger ensures that any time a row is inserted or updated This example trigger ensures that any time a row is inserted or updated
...@@ -4078,11 +4078,11 @@ CREATE TRIGGER emp_stamp BEFORE INSERT OR UPDATE ON emp ...@@ -4078,11 +4078,11 @@ CREATE TRIGGER emp_stamp BEFORE INSERT OR UPDATE ON emp
holds a row for each insert, update, or delete that occurs. This approach holds a row for each insert, update, or delete that occurs. This approach
can be thought of as auditing changes to a table. can be thought of as auditing changes to a table.
<xref linkend="plpgsql-trigger-audit-example"/> shows an example of an <xref linkend="plpgsql-trigger-audit-example"/> shows an example of an
audit trigger procedure in <application>PL/pgSQL</application>. audit trigger function in <application>PL/pgSQL</application>.
</para> </para>
<example id="plpgsql-trigger-audit-example"> <example id="plpgsql-trigger-audit-example">
<title>A <application>PL/pgSQL</application> Trigger Procedure For Auditing</title> <title>A <application>PL/pgSQL</application> Trigger Function For Auditing</title>
<para> <para>
This example trigger ensures that any insert, update or delete of a row This example trigger ensures that any insert, update or delete of a row
...@@ -4139,7 +4139,7 @@ AFTER INSERT OR UPDATE OR DELETE ON emp ...@@ -4139,7 +4139,7 @@ AFTER INSERT OR UPDATE OR DELETE ON emp
</para> </para>
<example id="plpgsql-view-trigger-audit-example"> <example id="plpgsql-view-trigger-audit-example">
<title>A <application>PL/pgSQL</application> View Trigger Procedure For Auditing</title> <title>A <application>PL/pgSQL</application> View Trigger Function For Auditing</title>
<para> <para>
This example uses a trigger on the view to make it updatable, and This example uses a trigger on the view to make it updatable, and
...@@ -4215,13 +4215,13 @@ INSTEAD OF INSERT OR UPDATE OR DELETE ON emp_view ...@@ -4215,13 +4215,13 @@ INSTEAD OF INSERT OR UPDATE OR DELETE ON emp_view
This technique is commonly used in Data Warehousing, where the tables This technique is commonly used in Data Warehousing, where the tables
of measured or observed data (called fact tables) might be extremely large. of measured or observed data (called fact tables) might be extremely large.
<xref linkend="plpgsql-trigger-summary-example"/> shows an example of a <xref linkend="plpgsql-trigger-summary-example"/> shows an example of a
trigger procedure in <application>PL/pgSQL</application> that maintains trigger function in <application>PL/pgSQL</application> that maintains
a summary table for a fact table in a data warehouse. a summary table for a fact table in a data warehouse.
</para> </para>
<example id="plpgsql-trigger-summary-example"> <example id="plpgsql-trigger-summary-example">
<title>A <application>PL/pgSQL</application> Trigger Procedure For Maintaining A Summary Table</title> <title>A <application>PL/pgSQL</application> Trigger Function For Maintaining A Summary Table</title>
<para> <para>
The schema detailed here is partly based on the <emphasis>Grocery Store The schema detailed here is partly based on the <emphasis>Grocery Store
...@@ -4445,7 +4445,7 @@ CREATE TRIGGER emp_audit_del ...@@ -4445,7 +4445,7 @@ CREATE TRIGGER emp_audit_del
<para> <para>
<application>PL/pgSQL</application> can be used to define <application>PL/pgSQL</application> can be used to define
<link linkend="event-triggers">event triggers</link>. <link linkend="event-triggers">event triggers</link>.
<productname>PostgreSQL</productname> requires that a procedure that <productname>PostgreSQL</productname> requires that a function that
is to be called as an event trigger must be declared as a function with is to be called as an event trigger must be declared as a function with
no arguments and a return type of <literal>event_trigger</literal>. no arguments and a return type of <literal>event_trigger</literal>.
</para> </para>
...@@ -4480,11 +4480,11 @@ CREATE TRIGGER emp_audit_del ...@@ -4480,11 +4480,11 @@ CREATE TRIGGER emp_audit_del
<para> <para>
<xref linkend="plpgsql-event-trigger-example"/> shows an example of an <xref linkend="plpgsql-event-trigger-example"/> shows an example of an
event trigger procedure in <application>PL/pgSQL</application>. event trigger function in <application>PL/pgSQL</application>.
</para> </para>
<example id="plpgsql-event-trigger-example"> <example id="plpgsql-event-trigger-example">
<title>A <application>PL/pgSQL</application> Event Trigger Procedure</title> <title>A <application>PL/pgSQL</application> Event Trigger Function</title>
<para> <para>
This example trigger simply raises a <literal>NOTICE</literal> message This example trigger simply raises a <literal>NOTICE</literal> message
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
PL/Tcl is a loadable procedural language for the PL/Tcl is a loadable procedural language for the
<productname>PostgreSQL</productname> database system <productname>PostgreSQL</productname> database system
that enables the <ulink url="http://www.tcl.tk/"> that enables the <ulink url="http://www.tcl.tk/">
Tcl language</ulink> to be used to write functions and Tcl language</ulink> to be used to write
trigger procedures. <productname>PostgreSQL</productname> functions.
</para> </para>
<!-- **** PL/Tcl overview **** --> <!-- **** PL/Tcl overview **** -->
...@@ -587,7 +587,7 @@ SELECT 'doesn''t' AS ret ...@@ -587,7 +587,7 @@ SELECT 'doesn''t' AS ret
</sect1> </sect1>
<sect1 id="pltcl-trigger"> <sect1 id="pltcl-trigger">
<title>Trigger Procedures in PL/Tcl</title> <title>Trigger Functions in PL/Tcl</title>
<indexterm> <indexterm>
<primary>trigger</primary> <primary>trigger</primary>
...@@ -595,13 +595,13 @@ SELECT 'doesn''t' AS ret ...@@ -595,13 +595,13 @@ SELECT 'doesn''t' AS ret
</indexterm> </indexterm>
<para> <para>
Trigger procedures can be written in PL/Tcl. Trigger functions can be written in PL/Tcl.
<productname>PostgreSQL</productname> requires that a procedure that is to be called <productname>PostgreSQL</productname> requires that a function that is to be called
as a trigger must be declared as a function with no arguments as a trigger must be declared as a function with no arguments
and a return type of <literal>trigger</literal>. and a return type of <literal>trigger</literal>.
</para> </para>
<para> <para>
The information from the trigger manager is passed to the procedure body The information from the trigger manager is passed to the function body
in the following variables: in the following variables:
<variablelist> <variablelist>
...@@ -619,7 +619,7 @@ SELECT 'doesn''t' AS ret ...@@ -619,7 +619,7 @@ SELECT 'doesn''t' AS ret
<term><varname>$TG_relid</varname></term> <term><varname>$TG_relid</varname></term>
<listitem> <listitem>
<para> <para>
The object ID of the table that caused the trigger procedure The object ID of the table that caused the trigger function
to be invoked. to be invoked.
</para> </para>
</listitem> </listitem>
...@@ -629,7 +629,7 @@ SELECT 'doesn''t' AS ret ...@@ -629,7 +629,7 @@ SELECT 'doesn''t' AS ret
<term><varname>$TG_table_name</varname></term> <term><varname>$TG_table_name</varname></term>
<listitem> <listitem>
<para> <para>
The name of the table that caused the trigger procedure The name of the table that caused the trigger function
to be invoked. to be invoked.
</para> </para>
</listitem> </listitem>
...@@ -639,7 +639,7 @@ SELECT 'doesn''t' AS ret ...@@ -639,7 +639,7 @@ SELECT 'doesn''t' AS ret
<term><varname>$TG_table_schema</varname></term> <term><varname>$TG_table_schema</varname></term>
<listitem> <listitem>
<para> <para>
The schema of the table that caused the trigger procedure The schema of the table that caused the trigger function
to be invoked. to be invoked.
</para> </para>
</listitem> </listitem>
...@@ -722,9 +722,9 @@ SELECT 'doesn''t' AS ret ...@@ -722,9 +722,9 @@ SELECT 'doesn''t' AS ret
<term><varname>$args</varname></term> <term><varname>$args</varname></term>
<listitem> <listitem>
<para> <para>
A Tcl list of the arguments to the procedure as given in the A Tcl list of the arguments to the function as given in the
<command>CREATE TRIGGER</command> statement. These arguments are also accessible as <command>CREATE TRIGGER</command> statement. These arguments are also accessible as
<literal>$1</literal> ... <literal>$<replaceable>n</replaceable></literal> in the procedure body. <literal>$1</literal> ... <literal>$<replaceable>n</replaceable></literal> in the function body.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -733,7 +733,7 @@ SELECT 'doesn''t' AS ret ...@@ -733,7 +733,7 @@ SELECT 'doesn''t' AS ret
</para> </para>
<para> <para>
The return value from a trigger procedure can be one of the strings The return value from a trigger function can be one of the strings
<literal>OK</literal> or <literal>SKIP</literal>, or a list of column name/value pairs. <literal>OK</literal> or <literal>SKIP</literal>, or a list of column name/value pairs.
If the return value is <literal>OK</literal>, If the return value is <literal>OK</literal>,
the operation (<command>INSERT</command>/<command>UPDATE</command>/<command>DELETE</command>) the operation (<command>INSERT</command>/<command>UPDATE</command>/<command>DELETE</command>)
...@@ -764,7 +764,7 @@ SELECT 'doesn''t' AS ret ...@@ -764,7 +764,7 @@ SELECT 'doesn''t' AS ret
</tip> </tip>
<para> <para>
Here's a little example trigger procedure that forces an integer value Here's a little example trigger function that forces an integer value
in a table to keep track of the number of updates that are performed on the in a table to keep track of the number of updates that are performed on the
row. For new rows inserted, the value is initialized to 0 and then row. For new rows inserted, the value is initialized to 0 and then
incremented on every update operation. incremented on every update operation.
...@@ -792,14 +792,14 @@ CREATE TRIGGER trig_mytab_modcount BEFORE INSERT OR UPDATE ON mytab ...@@ -792,14 +792,14 @@ CREATE TRIGGER trig_mytab_modcount BEFORE INSERT OR UPDATE ON mytab
FOR EACH ROW EXECUTE PROCEDURE trigfunc_modcount('modcnt'); FOR EACH ROW EXECUTE PROCEDURE trigfunc_modcount('modcnt');
</programlisting> </programlisting>
Notice that the trigger procedure itself does not know the column Notice that the trigger function itself does not know the column
name; that's supplied from the trigger arguments. This lets the name; that's supplied from the trigger arguments. This lets the
trigger procedure be reused with different tables. trigger function be reused with different tables.
</para> </para>
</sect1> </sect1>
<sect1 id="pltcl-event-trigger"> <sect1 id="pltcl-event-trigger">
<title>Event Trigger Procedures in PL/Tcl</title> <title>Event Trigger Functions in PL/Tcl</title>
<indexterm> <indexterm>
<primary>event trigger</primary> <primary>event trigger</primary>
...@@ -807,13 +807,13 @@ CREATE TRIGGER trig_mytab_modcount BEFORE INSERT OR UPDATE ON mytab ...@@ -807,13 +807,13 @@ CREATE TRIGGER trig_mytab_modcount BEFORE INSERT OR UPDATE ON mytab
</indexterm> </indexterm>
<para> <para>
Event trigger procedures can be written in PL/Tcl. Event trigger functions can be written in PL/Tcl.
<productname>PostgreSQL</productname> requires that a procedure that is <productname>PostgreSQL</productname> requires that a function that is
to be called as an event trigger must be declared as a function with no to be called as an event trigger must be declared as a function with no
arguments and a return type of <literal>event_trigger</literal>. arguments and a return type of <literal>event_trigger</literal>.
</para> </para>
<para> <para>
The information from the trigger manager is passed to the procedure body The information from the trigger manager is passed to the function body
in the following variables: in the following variables:
<variablelist> <variablelist>
...@@ -839,11 +839,11 @@ CREATE TRIGGER trig_mytab_modcount BEFORE INSERT OR UPDATE ON mytab ...@@ -839,11 +839,11 @@ CREATE TRIGGER trig_mytab_modcount BEFORE INSERT OR UPDATE ON mytab
</para> </para>
<para> <para>
The return value of the trigger procedure is ignored. The return value of the trigger function is ignored.
</para> </para>
<para> <para>
Here's a little example event trigger procedure that simply raises Here's a little example event trigger function that simply raises
a <literal>NOTICE</literal> message each time a supported command is a <literal>NOTICE</literal> message each time a supported command is
executed: executed:
......
...@@ -185,7 +185,7 @@ ALTER OPERATOR FAMILY <replaceable>name</replaceable> USING <replaceable class=" ...@@ -185,7 +185,7 @@ ALTER OPERATOR FAMILY <replaceable>name</replaceable> USING <replaceable class="
<term><replaceable class="parameter">support_number</replaceable></term> <term><replaceable class="parameter">support_number</replaceable></term>
<listitem> <listitem>
<para> <para>
The index method's support procedure number for a The index method's support function number for a
function associated with the operator family. function associated with the operator family.
</para> </para>
</listitem> </listitem>
...@@ -196,7 +196,7 @@ ALTER OPERATOR FAMILY <replaceable>name</replaceable> USING <replaceable class=" ...@@ -196,7 +196,7 @@ ALTER OPERATOR FAMILY <replaceable>name</replaceable> USING <replaceable class="
<listitem> <listitem>
<para> <para>
The name (optionally schema-qualified) of a function that is an index The name (optionally schema-qualified) of a function that is an index
method support procedure for the operator family. If no argument list method support function for the operator family. If no argument list
is specified, the name must be unique in its schema. is specified, the name must be unique in its schema.
</para> </para>
</listitem> </listitem>
......
...@@ -33,7 +33,7 @@ CREATE [ OR REPLACE ] [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="pa ...@@ -33,7 +33,7 @@ CREATE [ OR REPLACE ] [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="pa
<para> <para>
<command>CREATE LANGUAGE</command> registers a new <command>CREATE LANGUAGE</command> registers a new
procedural language with a <productname>PostgreSQL</productname> procedural language with a <productname>PostgreSQL</productname>
database. Subsequently, functions and trigger procedures can be database. Subsequently, functions and procedures can be
defined in this new language. defined in this new language.
</para> </para>
......
...@@ -38,7 +38,7 @@ CREATE OPERATOR CLASS <replaceable class="parameter">name</replaceable> [ DEFAUL ...@@ -38,7 +38,7 @@ CREATE OPERATOR CLASS <replaceable class="parameter">name</replaceable> [ DEFAUL
An operator class defines how a particular data type can be used with An operator class defines how a particular data type can be used with
an index. The operator class specifies that certain operators will fill an index. The operator class specifies that certain operators will fill
particular roles or <quote>strategies</quote> for this data type and this particular roles or <quote>strategies</quote> for this data type and this
index method. The operator class also specifies the support procedures to index method. The operator class also specifies the support functions to
be used by be used by
the index method when the operator class is selected for an the index method when the operator class is selected for an
index column. All the operators and functions used by an operator index column. All the operators and functions used by an operator
...@@ -201,7 +201,7 @@ CREATE OPERATOR CLASS <replaceable class="parameter">name</replaceable> [ DEFAUL ...@@ -201,7 +201,7 @@ CREATE OPERATOR CLASS <replaceable class="parameter">name</replaceable> [ DEFAUL
<term><replaceable class="parameter">support_number</replaceable></term> <term><replaceable class="parameter">support_number</replaceable></term>
<listitem> <listitem>
<para> <para>
The index method's support procedure number for a The index method's support function number for a
function associated with the operator class. function associated with the operator class.
</para> </para>
</listitem> </listitem>
...@@ -212,7 +212,7 @@ CREATE OPERATOR CLASS <replaceable class="parameter">name</replaceable> [ DEFAUL ...@@ -212,7 +212,7 @@ CREATE OPERATOR CLASS <replaceable class="parameter">name</replaceable> [ DEFAUL
<listitem> <listitem>
<para> <para>
The name (optionally schema-qualified) of a function that is an The name (optionally schema-qualified) of a function that is an
index method support procedure for the operator class. index method support function for the operator class.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
...@@ -94,7 +94,7 @@ CREATE OPERATOR <replaceable>name</replaceable> ( ...@@ -94,7 +94,7 @@ CREATE OPERATOR <replaceable>name</replaceable> (
<para> <para>
The <replaceable class="parameter">function_name</replaceable> The <replaceable class="parameter">function_name</replaceable>
procedure must have been previously defined using <command>CREATE function must have been previously defined using <command>CREATE
FUNCTION</command> and must be defined to accept the correct number FUNCTION</command> and must be defined to accept the correct number
of arguments (either one or two) of the indicated types. of arguments (either one or two) of the indicated types.
</para> </para>
...@@ -264,11 +264,11 @@ COMMUTATOR = OPERATOR(myschema.===) , ...@@ -264,11 +264,11 @@ COMMUTATOR = OPERATOR(myschema.===) ,
CREATE OPERATOR === ( CREATE OPERATOR === (
LEFTARG = box, LEFTARG = box,
RIGHTARG = box, RIGHTARG = box,
PROCEDURE = area_equal_procedure, PROCEDURE = area_equal_function,
COMMUTATOR = ===, COMMUTATOR = ===,
NEGATOR = !==, NEGATOR = !==,
RESTRICT = area_restriction_procedure, RESTRICT = area_restriction_function,
JOIN = area_join_procedure, JOIN = area_join_function,
HASHES, MERGES HASHES, MERGES
); );
</programlisting></para> </programlisting></para>
......
...@@ -348,7 +348,7 @@ UPDATE OF <replaceable>column_name1</replaceable> [, <replaceable>column_name2</ ...@@ -348,7 +348,7 @@ UPDATE OF <replaceable>column_name1</replaceable> [, <replaceable>column_name2</
<listitem> <listitem>
<para> <para>
This specifies whether the trigger procedure should be fired This specifies whether the trigger function should be fired
once for every row affected by the trigger event, or just once once for every row affected by the trigger event, or just once
per SQL statement. If neither is specified, <literal>FOR EACH per SQL statement. If neither is specified, <literal>FOR EACH
STATEMENT</literal> is the default. Constraint triggers can only STATEMENT</literal> is the default. Constraint triggers can only
......
This diff is collapsed.
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<literal>WHERE</literal>-clause operators that can be used with an index <literal>WHERE</literal>-clause operators that can be used with an index
(i.e., can be converted into an index-scan qualification). An (i.e., can be converted into an index-scan qualification). An
operator class can also specify some <firstterm>support operator class can also specify some <firstterm>support
procedures</firstterm> that are needed by the internal operations of the function</firstterm> that are needed by the internal operations of the
index method, but do not directly correspond to any index method, but do not directly correspond to any
<literal>WHERE</literal>-clause operator that can be used with the index. <literal>WHERE</literal>-clause operator that can be used with the index.
</para> </para>
......
...@@ -146,7 +146,7 @@ CREATE <optional>TRUSTED</optional> <optional>PROCEDURAL</optional> LANGUAGE <re ...@@ -146,7 +146,7 @@ CREATE <optional>TRUSTED</optional> <optional>PROCEDURAL</optional> LANGUAGE <re
the language does not grant access to data that the user would the language does not grant access to data that the user would
not otherwise have. Trusted languages are designed for ordinary not otherwise have. Trusted languages are designed for ordinary
database users (those without superuser privilege) and allows them database users (those without superuser privilege) and allows them
to safely create functions and trigger to safely create functions and
procedures. Since PL functions are executed inside the database procedures. Since PL functions are executed inside the database
server, the <literal>TRUSTED</literal> flag should only be given server, the <literal>TRUSTED</literal> flag should only be given
for languages that do not allow access to database server for languages that do not allow access to database server
...@@ -206,7 +206,7 @@ CREATE TRUSTED PROCEDURAL LANGUAGE plperl ...@@ -206,7 +206,7 @@ CREATE TRUSTED PROCEDURAL LANGUAGE plperl
VALIDATOR plperl_validator; VALIDATOR plperl_validator;
</programlisting> </programlisting>
then defines that the previously declared functions then defines that the previously declared functions
should be invoked for functions and trigger procedures where the should be invoked for functions and procedures where the
language attribute is <literal>plperl</literal>. language attribute is <literal>plperl</literal>.
</para> </para>
</example> </example>
......
...@@ -90,7 +90,7 @@ ginvalidate(Oid opclassoid) ...@@ -90,7 +90,7 @@ ginvalidate(Oid opclassoid)
{ {
ereport(INFO, ereport(INFO,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("operator family \"%s\" of access method %s contains support procedure %s with different left and right input types", errmsg("operator family \"%s\" of access method %s contains support function %s with different left and right input types",
opfamilyname, "gin", opfamilyname, "gin",
format_procedure(procform->amproc)))); format_procedure(procform->amproc))));
result = false; result = false;
......
...@@ -90,7 +90,7 @@ gistvalidate(Oid opclassoid) ...@@ -90,7 +90,7 @@ gistvalidate(Oid opclassoid)
{ {
ereport(INFO, ereport(INFO,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("operator family \"%s\" of access method %s contains support procedure %s with different left and right input types", errmsg("operator family \"%s\" of access method %s contains support function %s with different left and right input types",
opfamilyname, "gist", opfamilyname, "gist",
format_procedure(procform->amproc)))); format_procedure(procform->amproc))));
result = false; result = false;
......
...@@ -73,10 +73,10 @@ _hash_checkqual(IndexScanDesc scan, IndexTuple itup) ...@@ -73,10 +73,10 @@ _hash_checkqual(IndexScanDesc scan, IndexTuple itup)
} }
/* /*
* _hash_datum2hashkey -- given a Datum, call the index's hash procedure * _hash_datum2hashkey -- given a Datum, call the index's hash function
* *
* The Datum is assumed to be of the index's column type, so we can use the * The Datum is assumed to be of the index's column type, so we can use the
* "primary" hash procedure that's tracked for us by the generic index code. * "primary" hash function that's tracked for us by the generic index code.
*/ */
uint32 uint32
_hash_datum2hashkey(Relation rel, Datum key) _hash_datum2hashkey(Relation rel, Datum key)
......
...@@ -96,7 +96,7 @@ hashvalidate(Oid opclassoid) ...@@ -96,7 +96,7 @@ hashvalidate(Oid opclassoid)
{ {
ereport(INFO, ereport(INFO,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("operator family \"%s\" of access method %s contains support procedure %s with different left and right input types", errmsg("operator family \"%s\" of access method %s contains support function %s with different left and right input types",
opfamilyname, "hash", opfamilyname, "hash",
format_procedure(procform->amproc)))); format_procedure(procform->amproc))));
result = false; result = false;
...@@ -182,7 +182,7 @@ hashvalidate(Oid opclassoid) ...@@ -182,7 +182,7 @@ hashvalidate(Oid opclassoid)
result = false; result = false;
} }
/* There should be relevant hash procedures for each datatype */ /* There should be relevant hash functions for each datatype */
if (!list_member_oid(hashabletypes, oprform->amoplefttype) || if (!list_member_oid(hashabletypes, oprform->amoplefttype) ||
!list_member_oid(hashabletypes, oprform->amoprighttype)) !list_member_oid(hashabletypes, oprform->amoprighttype))
{ {
......
...@@ -96,7 +96,7 @@ spgvalidate(Oid opclassoid) ...@@ -96,7 +96,7 @@ spgvalidate(Oid opclassoid)
{ {
ereport(INFO, ereport(INFO,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("operator family \"%s\" of access method %s contains support procedure %s with different left and right input types", errmsg("operator family \"%s\" of access method %s contains support function %s with different left and right input types",
opfamilyname, "spgist", opfamilyname, "spgist",
format_procedure(procform->amproc)))); format_procedure(procform->amproc))));
result = false; result = false;
......
...@@ -517,7 +517,7 @@ DefineOpClass(CreateOpClassStmt *stmt) ...@@ -517,7 +517,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
if (item->number <= 0 || item->number > maxProcNumber) if (item->number <= 0 || item->number > maxProcNumber)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("invalid procedure number %d," errmsg("invalid function number %d,"
" must be between 1 and %d", " must be between 1 and %d",
item->number, maxProcNumber))); item->number, maxProcNumber)));
funcOid = LookupFuncWithArgs(OBJECT_FUNCTION, item->name, false); funcOid = LookupFuncWithArgs(OBJECT_FUNCTION, item->name, false);
...@@ -891,7 +891,7 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid, ...@@ -891,7 +891,7 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
if (item->number <= 0 || item->number > maxProcNumber) if (item->number <= 0 || item->number > maxProcNumber)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("invalid procedure number %d," errmsg("invalid function number %d,"
" must be between 1 and %d", " must be between 1 and %d",
item->number, maxProcNumber))); item->number, maxProcNumber)));
funcOid = LookupFuncWithArgs(OBJECT_FUNCTION, item->name, false); funcOid = LookupFuncWithArgs(OBJECT_FUNCTION, item->name, false);
...@@ -986,7 +986,7 @@ AlterOpFamilyDrop(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid, ...@@ -986,7 +986,7 @@ AlterOpFamilyDrop(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
if (item->number <= 0 || item->number > maxProcNumber) if (item->number <= 0 || item->number > maxProcNumber)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("invalid procedure number %d," errmsg("invalid function number %d,"
" must be between 1 and %d", " must be between 1 and %d",
item->number, maxProcNumber))); item->number, maxProcNumber)));
processTypesSpec(item->class_args, &lefttype, &righttype); processTypesSpec(item->class_args, &lefttype, &righttype);
...@@ -1141,11 +1141,11 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid) ...@@ -1141,11 +1141,11 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
if (procform->pronargs != 2) if (procform->pronargs != 2)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("btree comparison procedures must have two arguments"))); errmsg("btree comparison functions must have two arguments")));
if (procform->prorettype != INT4OID) if (procform->prorettype != INT4OID)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("btree comparison procedures must return integer"))); errmsg("btree comparison functions must return integer")));
/* /*
* If lefttype/righttype isn't specified, use the proc's input * If lefttype/righttype isn't specified, use the proc's input
...@@ -1162,11 +1162,11 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid) ...@@ -1162,11 +1162,11 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
procform->proargtypes.values[0] != INTERNALOID) procform->proargtypes.values[0] != INTERNALOID)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("btree sort support procedures must accept type \"internal\""))); errmsg("btree sort support functions must accept type \"internal\"")));
if (procform->prorettype != VOIDOID) if (procform->prorettype != VOIDOID)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("btree sort support procedures must return void"))); errmsg("btree sort support functions must return void")));
/* /*
* Can't infer lefttype/righttype from proc, so use default rule * Can't infer lefttype/righttype from proc, so use default rule
...@@ -1177,11 +1177,11 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid) ...@@ -1177,11 +1177,11 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
if (procform->pronargs != 5) if (procform->pronargs != 5)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("btree in_range procedures must have five arguments"))); errmsg("btree in_range functions must have five arguments")));
if (procform->prorettype != BOOLOID) if (procform->prorettype != BOOLOID)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("btree in_range procedures must return boolean"))); errmsg("btree in_range functions must return boolean")));
/* /*
* If lefttype/righttype isn't specified, use the proc's input * If lefttype/righttype isn't specified, use the proc's input
...@@ -1200,22 +1200,22 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid) ...@@ -1200,22 +1200,22 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
if (procform->pronargs != 1) if (procform->pronargs != 1)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("hash procedure 1 must have one argument"))); errmsg("hash function 1 must have one argument")));
if (procform->prorettype != INT4OID) if (procform->prorettype != INT4OID)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("hash procedure 1 must return integer"))); errmsg("hash function 1 must return integer")));
} }
else if (member->number == HASHEXTENDED_PROC) else if (member->number == HASHEXTENDED_PROC)
{ {
if (procform->pronargs != 2) if (procform->pronargs != 2)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("hash procedure 2 must have two arguments"))); errmsg("hash function 2 must have two arguments")));
if (procform->prorettype != INT8OID) if (procform->prorettype != INT8OID)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("hash procedure 2 must return bigint"))); errmsg("hash function 2 must return bigint")));
} }
/* /*
...@@ -1240,7 +1240,7 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid) ...@@ -1240,7 +1240,7 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
if (!OidIsValid(member->lefttype) || !OidIsValid(member->righttype)) if (!OidIsValid(member->lefttype) || !OidIsValid(member->righttype))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("associated data types must be specified for index support procedure"))); errmsg("associated data types must be specified for index support function")));
ReleaseSysCache(proctup); ReleaseSysCache(proctup);
} }
...@@ -1265,7 +1265,7 @@ addFamilyMember(List **list, OpFamilyMember *member, bool isProc) ...@@ -1265,7 +1265,7 @@ addFamilyMember(List **list, OpFamilyMember *member, bool isProc)
if (isProc) if (isProc)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("procedure number %d for (%s,%s) appears more than once", errmsg("function number %d for (%s,%s) appears more than once",
member->number, member->number,
format_type_be(member->lefttype), format_type_be(member->lefttype),
format_type_be(member->righttype)))); format_type_be(member->righttype))));
......
...@@ -3907,7 +3907,7 @@ listEventTriggers(const char *pattern, bool verbose) ...@@ -3907,7 +3907,7 @@ listEventTriggers(const char *pattern, bool verbose)
gettext_noop("always"), gettext_noop("always"),
gettext_noop("disabled"), gettext_noop("disabled"),
gettext_noop("Enabled"), gettext_noop("Enabled"),
gettext_noop("Procedure"), gettext_noop("Function"),
gettext_noop("Tags")); gettext_noop("Tags"));
if (verbose) if (verbose)
appendPQExpBuffer(&buf, appendPQExpBuffer(&buf,
......
...@@ -263,7 +263,7 @@ typedef struct HashMetaPageData ...@@ -263,7 +263,7 @@ typedef struct HashMetaPageData
* allocated */ * allocated */
uint32 hashm_firstfree; /* lowest-number free ovflpage (bit#) */ uint32 hashm_firstfree; /* lowest-number free ovflpage (bit#) */
uint32 hashm_nmaps; /* number of bitmap pages */ uint32 hashm_nmaps; /* number of bitmap pages */
RegProcedure hashm_procid; /* hash procedure id from pg_proc */ RegProcedure hashm_procid; /* hash function id from pg_proc */
uint32 hashm_spares[HASH_MAX_SPLITPOINTS]; /* spare pages before each uint32 hashm_spares[HASH_MAX_SPLITPOINTS]; /* spare pages before each
* splitpoint */ * splitpoint */
BlockNumber hashm_mapp[HASH_MAX_BITMAPS]; /* blknos of ovfl bitmaps */ BlockNumber hashm_mapp[HASH_MAX_BITMAPS]; /* blknos of ovfl bitmaps */
...@@ -338,15 +338,15 @@ typedef HashMetaPageData *HashMetaPage; ...@@ -338,15 +338,15 @@ typedef HashMetaPageData *HashMetaPage;
/* /*
* When a new operator class is declared, we require that the user supply * When a new operator class is declared, we require that the user supply
* us with an amproc procedure for hashing a key of the new type, returning * us with an amproc function for hashing a key of the new type, returning
* a 32-bit hash value. We call this the "standard" hash procedure. We * a 32-bit hash value. We call this the "standard" hash function. We
* also allow an optional "extended" hash procedure which accepts a salt and * also allow an optional "extended" hash function which accepts a salt and
* returns a 64-bit hash value. This is highly recommended but, for reasons * returns a 64-bit hash value. This is highly recommended but, for reasons
* of backward compatibility, optional. * of backward compatibility, optional.
* *
* When the salt is 0, the low 32 bits of the value returned by the extended * When the salt is 0, the low 32 bits of the value returned by the extended
* hash procedure should match the value that would have been returned by the * hash function should match the value that would have been returned by the
* standard hash procedure. * standard hash function.
*/ */
#define HASHSTANDARD_PROC 1 #define HASHSTANDARD_PROC 1
#define HASHEXTENDED_PROC 2 #define HASHEXTENDED_PROC 2
......
...@@ -354,9 +354,9 @@ ERROR: invalid operator number 0, must be between 1 and 5 ...@@ -354,9 +354,9 @@ ERROR: invalid operator number 0, must be between 1 and 5
ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 1 < ; -- operator without argument types ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 1 < ; -- operator without argument types
ERROR: operator argument types must be specified in ALTER OPERATOR FAMILY ERROR: operator argument types must be specified in ALTER OPERATOR FAMILY
ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 0 btint42cmp(int4, int2); -- function number should be between 1 and 5 ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 0 btint42cmp(int4, int2); -- function number should be between 1 and 5
ERROR: invalid procedure number 0, must be between 1 and 3 ERROR: invalid function number 0, must be between 1 and 3
ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 6 btint42cmp(int4, int2); -- function number should be between 1 and 5 ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 6 btint42cmp(int4, int2); -- function number should be between 1 and 5
ERROR: invalid procedure number 6, must be between 1 and 3 ERROR: invalid function number 6, must be between 1 and 3
ALTER OPERATOR FAMILY alt_opf4 USING btree ADD STORAGE invalid_storage; -- Ensure STORAGE is not a part of ALTER OPERATOR FAMILY ALTER OPERATOR FAMILY alt_opf4 USING btree ADD STORAGE invalid_storage; -- Ensure STORAGE is not a part of ALTER OPERATOR FAMILY
ERROR: STORAGE cannot be specified in ALTER OPERATOR FAMILY ERROR: STORAGE cannot be specified in ALTER OPERATOR FAMILY
DROP OPERATOR FAMILY alt_opf4 USING btree; DROP OPERATOR FAMILY alt_opf4 USING btree;
...@@ -412,7 +412,7 @@ BEGIN TRANSACTION; ...@@ -412,7 +412,7 @@ BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf12 USING btree; CREATE OPERATOR FAMILY alt_opf12 USING btree;
CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL; CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
ALTER OPERATOR FAMILY alt_opf12 USING btree ADD FUNCTION 1 fn_opf12(int4, int2); ALTER OPERATOR FAMILY alt_opf12 USING btree ADD FUNCTION 1 fn_opf12(int4, int2);
ERROR: btree comparison procedures must return integer ERROR: btree comparison functions must return integer
DROP OPERATOR FAMILY alt_opf12 USING btree; DROP OPERATOR FAMILY alt_opf12 USING btree;
ERROR: current transaction is aborted, commands ignored until end of transaction block ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK; ROLLBACK;
...@@ -421,7 +421,7 @@ BEGIN TRANSACTION; ...@@ -421,7 +421,7 @@ BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf13 USING hash; CREATE OPERATOR FAMILY alt_opf13 USING hash;
CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL; CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
ALTER OPERATOR FAMILY alt_opf13 USING hash ADD FUNCTION 1 fn_opf13(int4); ALTER OPERATOR FAMILY alt_opf13 USING hash ADD FUNCTION 1 fn_opf13(int4);
ERROR: hash procedure 1 must return integer ERROR: hash function 1 must return integer
DROP OPERATOR FAMILY alt_opf13 USING hash; DROP OPERATOR FAMILY alt_opf13 USING hash;
ERROR: current transaction is aborted, commands ignored until end of transaction block ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK; ROLLBACK;
...@@ -430,7 +430,7 @@ BEGIN TRANSACTION; ...@@ -430,7 +430,7 @@ BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf14 USING btree; CREATE OPERATOR FAMILY alt_opf14 USING btree;
CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL; CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
ALTER OPERATOR FAMILY alt_opf14 USING btree ADD FUNCTION 1 fn_opf14(int4); ALTER OPERATOR FAMILY alt_opf14 USING btree ADD FUNCTION 1 fn_opf14(int4);
ERROR: btree comparison procedures must have two arguments ERROR: btree comparison functions must have two arguments
DROP OPERATOR FAMILY alt_opf14 USING btree; DROP OPERATOR FAMILY alt_opf14 USING btree;
ERROR: current transaction is aborted, commands ignored until end of transaction block ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK; ROLLBACK;
...@@ -439,7 +439,7 @@ BEGIN TRANSACTION; ...@@ -439,7 +439,7 @@ BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf15 USING hash; CREATE OPERATOR FAMILY alt_opf15 USING hash;
CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL; CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
ALTER OPERATOR FAMILY alt_opf15 USING hash ADD FUNCTION 1 fn_opf15(int4, int2); ALTER OPERATOR FAMILY alt_opf15 USING hash ADD FUNCTION 1 fn_opf15(int4, int2);
ERROR: hash procedure 1 must have one argument ERROR: hash function 1 must have one argument
DROP OPERATOR FAMILY alt_opf15 USING hash; DROP OPERATOR FAMILY alt_opf15 USING hash;
ERROR: current transaction is aborted, commands ignored until end of transaction block ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK; ROLLBACK;
...@@ -447,7 +447,7 @@ ROLLBACK; ...@@ -447,7 +447,7 @@ ROLLBACK;
-- without defining left / right type in ALTER OPERATOR FAMILY ... ADD FUNCTION -- without defining left / right type in ALTER OPERATOR FAMILY ... ADD FUNCTION
CREATE OPERATOR FAMILY alt_opf16 USING gist; CREATE OPERATOR FAMILY alt_opf16 USING gist;
ALTER OPERATOR FAMILY alt_opf16 USING gist ADD FUNCTION 1 btint42cmp(int4, int2); ALTER OPERATOR FAMILY alt_opf16 USING gist ADD FUNCTION 1 btint42cmp(int4, int2);
ERROR: associated data types must be specified for index support procedure ERROR: associated data types must be specified for index support function
DROP OPERATOR FAMILY alt_opf16 USING gist; DROP OPERATOR FAMILY alt_opf16 USING gist;
-- Should fail. duplicate operator number / function number in ALTER OPERATOR FAMILY ... ADD FUNCTION -- Should fail. duplicate operator number / function number in ALTER OPERATOR FAMILY ... ADD FUNCTION
CREATE OPERATOR FAMILY alt_opf17 USING btree; CREATE OPERATOR FAMILY alt_opf17 USING btree;
...@@ -464,7 +464,7 @@ ALTER OPERATOR FAMILY alt_opf17 USING btree ADD ...@@ -464,7 +464,7 @@ ALTER OPERATOR FAMILY alt_opf17 USING btree ADD
OPERATOR 5 > (int4, int2) , OPERATOR 5 > (int4, int2) ,
FUNCTION 1 btint42cmp(int4, int2) , FUNCTION 1 btint42cmp(int4, int2) ,
FUNCTION 1 btint42cmp(int4, int2); -- procedure 1 appears twice in same statement FUNCTION 1 btint42cmp(int4, int2); -- procedure 1 appears twice in same statement
ERROR: procedure number 1 for (integer,smallint) appears more than once ERROR: function number 1 for (integer,smallint) appears more than once
ALTER OPERATOR FAMILY alt_opf17 USING btree ADD ALTER OPERATOR FAMILY alt_opf17 USING btree ADD
OPERATOR 1 < (int4, int2) , OPERATOR 1 < (int4, int2) ,
OPERATOR 2 <= (int4, int2) , OPERATOR 2 <= (int4, int2) ,
......
...@@ -185,11 +185,11 @@ CREATE OPERATOR === ...@@ -185,11 +185,11 @@ CREATE OPERATOR ===
( (
"Leftarg" = box, "Leftarg" = box,
"Rightarg" = box, "Rightarg" = box,
"Procedure" = area_equal_procedure, "Procedure" = area_equal_function,
"Commutator" = ===, "Commutator" = ===,
"Negator" = !==, "Negator" = !==,
"Restrict" = area_restriction_procedure, "Restrict" = area_restriction_function,
"Join" = area_join_procedure, "Join" = area_join_function,
"Hashes", "Hashes",
"Merges" "Merges"
); );
......
...@@ -189,11 +189,11 @@ CREATE OPERATOR === ...@@ -189,11 +189,11 @@ CREATE OPERATOR ===
( (
"Leftarg" = box, "Leftarg" = box,
"Rightarg" = box, "Rightarg" = box,
"Procedure" = area_equal_procedure, "Procedure" = area_equal_function,
"Commutator" = ===, "Commutator" = ===,
"Negator" = !==, "Negator" = !==,
"Restrict" = area_restriction_procedure, "Restrict" = area_restriction_function,
"Join" = area_join_procedure, "Join" = area_join_function,
"Hashes", "Hashes",
"Merges" "Merges"
); );
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