@@ -5235,8 +5235,9 @@ DROP TABLE products CASCADE;
5235
5235
</para>
5236
5236
5237
5237
<para>
5238
- For user-defined functions, <productname>PostgreSQL</productname> tracks
5239
- dependencies associated with a function's externally-visible properties,
5238
+ For a user-defined function or procedure whose body is defined as a string
5239
+ literal, <productname>PostgreSQL</productname> tracks
5240
+ dependencies associated with the function's externally-visible properties,
5240
5241
such as its argument and result types, but <emphasis>not</emphasis> dependencies
5241
5242
that could only be known by examining the function body. As an example,
5242
5243
consider this situation:
@@ -5264,6 +5265,23 @@ CREATE FUNCTION get_color_note (rainbow) RETURNS text AS
5264
5265
table is missing, though executing it would cause an error; creating a new
5265
5266
table of the same name would allow the function to work again.
5266
5267
</para>
5268
+
5269
+ <para>
5270
+ On the other hand, for a SQL-language function or procedure whose body
5271
+ is written in SQL-standard style, the body is parsed at function
5272
+ definition time and all dependencies recognized by the parser are
5273
+ stored. Thus, if we write the function above as
5274
+
5275
+ <programlisting>
5276
+ CREATE FUNCTION get_color_note (rainbow) RETURNS text
5277
+ BEGIN ATOMIC
5278
+ SELECT note FROM my_colors WHERE color = $1;
5279
+ END;
5280
+ </programlisting>
5281
+
5282
+ then the function's dependency on the <structname>my_colors</structname>
5283
+ table will be known and enforced by <command>DROP</command>.
5284
+ </para>
5267
5285
</sect1>
5268
5286
5269
5287
</chapter>
0 commit comments