Temporary table weirdness

Поиск
Список
Период
Сортировка
Искать
От
Joseph Barillari
Тема
Temporary table weirdness
Дата
Msg-id
m3elgzni0f.fsf@washer.barillari.org
Список
Дерево обсуждения
Temporary table weirdness Joseph Barillari <jbarilla@princeton.edu>
Re: Temporary table weirdness Bruce Momjian <pgman@candle.pha.pa.us>
Re: Temporary table weirdness Tom Lane <tgl@sss.pgh.pa.us>
Re: Temporary table weirdness Bruce Momjian <pgman@candle.pha.pa.us>
Re: Temporary table weirdness Joseph Barillari <jbarilla@princeton.edu>
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
В списке pgsql-sql по дате отправления
От: Josh Berkus
Дата:
Сообщение: Re: IN, EXISTS or ANY?
От: Christoph Haller
Дата:
FAQ