pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joseph Barillari <jbarilla@princeton.edu>
To: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Temporary table weirdness
Date: Mon, 29 Apr 2002 02:20:00 -0400
Message-ID: <m3elgzni0f.fsf@washer.barillari.org> (raw)

Hi,

I have a function that creates and destroys temporary tables in the
course of its work, and have run into trouble if the function
is executed more than once during a database session. A small
proof-of-concept is attached below:

cal=> create or replace function frob() returns integer as 'begin create temporary table foo(bar INT); insert into foo (bar) values (1); drop table foo; return 1; end;' language 'plpgsql';
CREATE

(seems pretty standard)

cal=> select frob();
 frob 
------
    1
(1 row)

(OK so far...)

cal=> select frob();
NOTICE:  Error occurred while executing PL/pgSQL function frob
NOTICE:  line 1 at SQL statement
ERROR:  Relation 68141 does not exist

On the second call, PostgreSQL chokes. Any suggestions as to why
would be appreciated.

Oddly enough, redefining the function eliminates the error for the
next function call.

Thanks,

Joe

view thread (5+ messages)  latest in thread

Message-ID: <m3elgzni0f.fsf@washer.barillari.org>
Permalink:  ../m3elgzni0f.fsf@washer.barillari.org/
Also on:    postgresql.org/message-id/m3elgzni0f.fsf@washer.barillari.org

 · 

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: jbarilla@princeton.edu
  Subject: Re: Temporary table weirdness
  In-Reply-To: <m3elgzni0f.fsf@washer.barillari.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