@@ -5072,8 +5072,9 @@ DROP TABLE products CASCADE;
5072
5072
</para>
5073
5073
5074
5074
<para>
5075
- For user-defined functions, <productname>PostgreSQL</productname> tracks
5076
- dependencies associated with a function's externally-visible properties,
5075
+ For a user-defined function or procedure whose body is defined as a string
5076
+ literal, <productname>PostgreSQL</productname> tracks
5077
+ dependencies associated with the function's externally-visible properties,
5077
5078
such as its argument and result types, but <emphasis>not</emphasis> dependencies
5078
5079
that could only be known by examining the function body. As an example,
5079
5080
consider this situation:
@@ -5101,6 +5102,23 @@ CREATE FUNCTION get_color_note (rainbow) RETURNS text AS
5101
5102
table is missing, though executing it would cause an error; creating a new
5102
5103
table of the same name would allow the function to work again.
5103
5104
</para>
5105
+
5106
+ <para>
5107
+ On the other hand, for a SQL-language function or procedure whose body
5108
+ is written in SQL-standard style, the body is parsed at function
5109
+ definition time and all dependencies recognized by the parser are
5110
+ stored. Thus, if we write the function above as
5111
+
5112
+ <programlisting>
5113
+ CREATE FUNCTION get_color_note (rainbow) RETURNS text
5114
+ BEGIN ATOMIC
5115
+ SELECT note FROM my_colors WHERE color = $1;
5116
+ END;
5117
+ </programlisting>
5118
+
5119
+ then the function's dependency on the <structname>my_colors</structname>
5120
+ table will be known and enforced by <command>DROP</command>.
5121
+ </para>
5104
5122
</sect1>
5105
5123
5106
5124
</chapter>
0 commit comments