aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2023-06-04 13:27:34 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2023-06-04 13:27:34 -0400
commit0211544969b589e49c40d113822162ee3ed78bd6 (patch)
tree143b3b94586a3875abd64d20e31aaa2af919bcc6 /doc/src
parent01610747867ff26ca62d099e83e62d97730c40c1 (diff)
downloadpostgresql-0211544969b589e49c40d113822162ee3ed78bd6.tar.gz
postgresql-0211544969b589e49c40d113822162ee3ed78bd6.zip
Doc: explain about dependency tracking for new-style SQL functions.
5.14 Dependency Tracking was not updated when we added new-style SQL functions. Improve that. Noted by Sami Imseih. Back-patch to v14 where new-style SQL functions came in. Discussion: https://postgr.es/m/2C1933AB-C2F8-499B-9D18-4AC1882256A0@amazon.com
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/ddl.sgml22
1 files changed, 20 insertions, 2 deletions
diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 458b89c0cba..e32f8253d03 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -5235,8 +5235,9 @@ DROP TABLE products CASCADE;
</para>
<para>
- For user-defined functions, <productname>PostgreSQL</productname> tracks
- dependencies associated with a function's externally-visible properties,
+ For a user-defined function or procedure whose body is defined as a string
+ literal, <productname>PostgreSQL</productname> tracks
+ dependencies associated with the function's externally-visible properties,
such as its argument and result types, but <emphasis>not</emphasis> dependencies
that could only be known by examining the function body. As an example,
consider this situation:
@@ -5264,6 +5265,23 @@ CREATE FUNCTION get_color_note (rainbow) RETURNS text AS
table is missing, though executing it would cause an error; creating a new
table of the same name would allow the function to work again.
</para>
+
+ <para>
+ On the other hand, for a SQL-language function or procedure whose body
+ is written in SQL-standard style, the body is parsed at function
+ definition time and all dependencies recognized by the parser are
+ stored. Thus, if we write the function above as
+
+<programlisting>
+CREATE FUNCTION get_color_note (rainbow) RETURNS text
+BEGIN ATOMIC
+ SELECT note FROM my_colors WHERE color = $1;
+END;
+</programlisting>
+
+ then the function's dependency on the <structname>my_colors</structname>
+ table will be known and enforced by <command>DROP</command>.
+ </para>
</sect1>
</chapter>