diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2014-06-19 12:33:56 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2014-06-19 12:33:56 -0400 |
commit | f28d9b10f73440adcb2e094440b4b213673e491b (patch) | |
tree | 4ab863c724bbc7091115bf782ada3e0a42bd074b /doc/src | |
parent | bfaa8c665fcbd4388e01c53c4b5137f1f53d1787 (diff) | |
download | postgresql-f28d9b10f73440adcb2e094440b4b213673e491b.tar.gz postgresql-f28d9b10f73440adcb2e094440b4b213673e491b.zip |
Document SQL functions' behavior of parsing the whole function at once.
Haribabu Kommi, somewhat rewritten by me
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/xfunc.sgml | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml index 941b101f393..d759f3746b2 100644 --- a/doc/src/sgml/xfunc.sgml +++ b/doc/src/sgml/xfunc.sgml @@ -143,6 +143,21 @@ SELECT clean_emp(); </screen> </para> + <note> + <para> + The entire body of a SQL function is parsed before any of it is + executed. While a SQL function can contain commands that alter + the system catalogs (e.g., <command>CREATE TABLE</>), the effects + of such commands will not be visible during parse analysis of + later commands in the function. Thus, for example, + <literal>CREATE TABLE foo (...); INSERT INTO foo VALUES(...);</literal> + will not work as desired if packaged up into a single SQL function, + since <structname>foo</> won't exist yet when the <command>INSERT</> + command is parsed. It's recommended to use <application>PL/PgSQL</> + instead of a SQL function in this type of situation. + </para> + </note> + <para> The syntax of the <command>CREATE FUNCTION</command> command requires the function body to be written as a string constant. It is usually |