pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <pgman@candle.pha.pa.us>
To: jack <datactrl@tpg.com.au>
Cc: pgsql-sql@postgresql.org
Subject: Re:
Date: Mon, 8 Jul 2002 14:40:39 -0400 (EDT)
Message-ID: <200207081840.g68IedD14328@candle.pha.pa.us> (raw)
In-Reply-To: <000201c2265f$793f85f0$1400a8c0@jac>

jack wrote:
> Hi,
> Regarding temp tables in the same connection session. If there is SQL
> procedure creating temp tables, process temp tables and drop all the temp
> tables finally. This SQL procedure can't run twice in the same session.
> Because all the temp tables are referred to the first physical temp tables.
> I posted this question couple months ago and the final reply is that in the
> future version, all the sql procedures, which use temp tables, will be
> forced to re-compile though it's been used in the session.
> 
> Now, my question is, if it has been done, do I still need to drop all the
> temp tables before I re-run the same SQL procedure in the same session?

Actually, we recomment using EXECUTE for any temp table access from
pl/pgsql stored procedures.  We even have an FAQ item now:

    <H4><A name="4.26">4.26</A>) Why can't I reliably create/drop
    temporary tables in PL/PgSQL functions?</H4>
    PL/PgSQL caches function contents, and an unfortunate side effect
    is that if a PL/PgSQL function accesses a temporary table, and that
    table is later dropped and recreated, and the function called
    again, the function will fail because the cached function contents
    still point to the old temporary table. The solution is to use
    <SMALL>EXECUTE</SMALL> for temporary table access in PL/PgSQL. This
    will cause the query to be reparsed every time. 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026





view thread (4+ messages)

Message-ID: <200207081840.g68IedD14328@candle.pha.pa.us>
Permalink:  ../200207081840.g68IedD14328@candle.pha.pa.us/
Also on:    postgresql.org/message-id/200207081840.g68IedD14328@candle.pha.pa.us

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: pgman@candle.pha.pa.us, datactrl@tpg.com.au
  Subject: Re:
  In-Reply-To: <200207081840.g68IedD14328@candle.pha.pa.us>

* 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