Re: "CREATE TEMPORARY TABLE" does not work in SQL language function? - Mailing list pgsql-general

From Tom Lane
Subject Re: "CREATE TEMPORARY TABLE" does not work in SQL language function?
Date
Msg-id 18705.1359661936@sss.pgh.pa.us
Whole thread Raw
In response to "CREATE TEMPORARY TABLE" does not work in SQL language function?  ("David Johnston" <polobo@yahoo.com>)
List pgsql-general
"David Johnston" <polobo@yahoo.com> writes:
> The only difference between the following two "CREATE FUNCTION" command is
> the language in which they are written.

The reason the SQL function doesn't work is that SQL functions parse and
analyze their whole bodies before beginning execution --- so "temptbl"
doesn't exist yet when the SELECT is analyzed.  It's not about temp
tables as such, but rather that any DDL that affects the meaning of
later statements is problematic.

IIRC, there have been a few discussions about changing this behavior,
but nothing's been done, partly out of fear of breaking existing
applications.

            regards, tom lane


pgsql-general by date:

Previous
From: Vincent Veyron
Date:
Subject: Re: SQL sentence to insert where updated rows is zero...
Next
From: Kevin Grittner
Date:
Subject: Re: Pg & Tcl - is it dying out?