From: Abhijit Menon-Sen <ams@2ndQuadrant.com>
To: Haribabu Kommi <kommi.haribabu@gmail.com>
Cc: David Johnston <polobo@yahoo.com>
Cc: pgsql-hackers@postgresql.org
Subject: [REVIEW] Re: Re: BUG #9578: Undocumented behaviour for temp tables created inside query language (SQL) functions
Date: Mon, 16 Jun 2014 20:00:53 +0530
Message-ID: <20140616143053.GA13668@toroid.org> (raw)
In-Reply-To: <CAJrrPGdUM9Et_VyeWHEpDxuKmCF2P0cM8kyTo52ww+3BefF62w@mail.gmail.com>
References: <20140315165011.20722.74795@wrigleys.postgresql.org>
<CAJrrPGcgfBPvJwGfvChVKYJKvChMxs62eb_bnMPcyzCR8TAmCg@mail.gmail.com>
<1395027732507-5796262.post@n5.nabble.com>
<CAJrrPGfqDmGa7uMtZgazsUGz3Eut1xRJw4qUeb0s0kyQMqbv0g@mail.gmail.com>
<1395033331936-5796272.post@n5.nabble.com>
<CAJrrPGdUM9Et_VyeWHEpDxuKmCF2P0cM8kyTo52ww+3BefF62w@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
(Cc: to pgsql-bugs dropped.)
At 2014-03-17 18:24:55 +1100, kommi.haribabu@gmail.com wrote:
>
> *** a/doc/src/sgml/xfunc.sgml
> --- b/doc/src/sgml/xfunc.sgml
> ***************
> *** 153,159 **** SELECT clean_emp();
> --- 153,186 ----
> (<literal>\</>) (assuming escape string syntax) in the body of
> the function (see <xref linkend="sql-syntax-strings">).
> </para>
> +
> + <sect2 id="xfunc-sql-function-parsing-mechanism">
> + <title>Parsing mechanism of a function</title>
>
> + <indexterm>
> + <primary>function</primary>
> + <secondary>parsing mechanism</secondary>
> + </indexterm>
I suggest "Catalog changes within functions" instead of the above title.
> + <para>
> + The body of an SQL function is parsed as if it were a single - multi-part
> + statement and thus uses a constant snapshot of the system catalogs for
> + every sub-statement therein. Commands that alter the catalog will likely not
> + work as expected.
> + </para>
> +
> + <para>
> + For example: Issuing "CREATE TEMP TABLE" within an SQL function will add
> + the table to the catalog but subsequent statements in the same function will
> + not see those additions and thus the temporary table will be invisible to them.
> + </para>
> +
> + <para>
> + Thus it is generally advised that <application>PL/pgSQL</> be used, instead of
> + <acronym>SQL</acronym>, when any catalog visibilities are required in the same function.
> + </para>
> + </sect2>
I don't think that much text is warranted. I suggest something like the
following condensed wording:
<para>
The body of an SQL function is parsed as if it were a single
multi-part statement, using a constant snapshot of the system
catalogs. The effect of any commands that alter the catalogs
(e.g. "CREATE TEMP TABLE") will therefore not be visible to
subsequent commands in the function body.
</para>
<para>
The recommended workaround is to use <application>PL/PgSQL</>.
</para>
Does that seem sensible to you?
-- Abhijit
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: ams@2ndQuadrant.com, kommi.haribabu@gmail.com, polobo@yahoo.com, pgsql-hackers@postgresql.org
Subject: Re: [REVIEW] Re: Re: BUG #9578: Undocumented behaviour for temp tables created inside query language (SQL) functions
In-Reply-To: <20140616143053.GA13668@toroid.org>
References: <20140315165011.20722.74795@wrigleys.postgresql.org> <CAJrrPGcgfBPvJwGfvChVKYJKvChMxs62eb_bnMPcyzCR8TAmCg@mail.gmail.com> <1395027732507-5796262.post@n5.nabble.com> <CAJrrPGfqDmGa7uMtZgazsUGz3Eut1xRJw4qUeb0s0kyQMqbv0g@mail.gmail.com> <1395033331936-5796272.post@n5.nabble.com> <CAJrrPGdUM9Et_VyeWHEpDxuKmCF2P0cM8kyTo52ww+3BefF62w@mail.gmail.com> <20140616143053.GA13668@toroid.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox