Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf28d9b1

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

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎doc/src/sgml/xfunc.sgml

Lines changed: 15 additions & 0 deletions
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)

[8]ページ先頭

©2009-2025 Movatter.jp