Re: Temporary tables inside functions problem

From: Ian Barwick <barwick(at)gmx(dot)net>
To: Avi Schwartz <avi(at)CFFtechnologies(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Temporary tables inside functions problem
Date: 2003-06-08 19:54:59
Message-ID: 200306082154.59758.barwick@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sunday 08 June 2003 01:50, Avi Schwartz wrote:
(...)
> It seems that the error occurs not when creating the temporary tables,
> but rather when attempting to insert into them.
>
> I am sure there is a logical explanation, although I can find it. Any
> idea what is the problem and how I can fix it?

Possibly this item from the FAQ might help:
http://www.postgresql.org/docs/faqs/FAQ.html#4.26

4.26) Why can't I reliably create/drop temporary tables in PL/PgSQL functions?

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 EXECUTE for temporary table access in PL/PgSQL. This will
cause the query to be reparsed every time.

Ian Barwick
barwick(at)gmx(dot)net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Arjen van der Meijden 2003-06-08 19:55:19 Re: Linux 2.6 kernel,
Previous Message Stephan Szabo 2003-06-08 19:53:01 Re: Temporary tables inside functions problem