Content-Length: 272540 | pFad | http://github.com/tonybelloni/postgres/commit/f28d9b10f73440adcb2e094440b4b213673e491b

5A Document SQL functions' behavior of parsing the whole function at once. · tonybelloni/postgres@f28d9b1 · GitHub
Skip to content

Commit f28d9b1

Browse files
committed
Document SQL functions' behavior of parsing the whole function at once.
Haribabu Kommi, somewhat rewritten by me
1 parent bfaa8c6 commit f28d9b1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Diff for: doc/src/sgml/xfunc.sgml

+15
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,21 @@ SELECT clean_emp();
143143
</screen>
144144
</para>
145145

146+
<note>
147+
<para>
148+
The entire body of a SQL function is parsed before any of it is
149+
executed. While a SQL function can contain commands that alter
150+
the system catalogs (e.g., <command>CREATE TABLE</>), the effects
151+
of such commands will not be visible during parse analysis of
152+
later commands in the function. Thus, for example,
153+
<literal>CREATE TABLE foo (...); INSERT INTO foo VALUES(...);</literal>
154+
will not work as desired if packaged up into a single SQL function,
155+
since <structname>foo</> won't exist yet when the <command>INSERT</>
156+
command is parsed. It's recommended to use <application>PL/PgSQL</>
157+
instead of a SQL function in this type of situation.
158+
</para>
159+
</note>
160+
146161
<para>
147162
The syntax of the <command>CREATE FUNCTION</command> command requires
148163
the function body to be written as a string constant. It is usually

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/tonybelloni/postgres/commit/f28d9b10f73440adcb2e094440b4b213673e491b

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy