Unix Technical Forum

basic temp table question

This is a discussion on basic temp table question within the Pgsql General forums, part of the PostgreSQL category; --> Hello, The first time I run a query against this function (using Npgsql): declare r_cursor1 cursor for SELECT * ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 07:51 PM
L. Fletcher
 
Posts: n/a
Default basic temp table question

Hello,

The first time I run a query against this function (using Npgsql):

declare
r_cursor1 cursor for

SELECT * from tmp_table;

begin

CREATE TEMPORARY TABLE tmp_table
(
testcol integer
) ON COMMIT DROP;

INSERT INTO tmp_table
SELECT 0;

open r_cursor1;

return 0;
end;

I get this error:

ERROR: XX000: relation 1090457025 is still open

All subsequent times I get this error:

ERROR: 42P01: relation with OID 1090457025 does not exist

What am I doing wrong?

(Sorry if this is a basic question.)

Thanks in advance...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 07:51 PM
Tom Lane
 
Posts: n/a
Default Re: basic temp table question

"L. Fletcher" <lucasf@vagabond-software.com> writes:
> I get this error:
> ERROR: XX000: relation 1090457025 is still open


This is an 8.0 bug fixed in 8.0.1.

> All subsequent times I get this error:
> ERROR: 42P01: relation with OID 1090457025 does not exist=20


This is because plpgsql caches plans and therefore can't cope with
tmp_table not being the identical same table from run to run of the
function. Sooner or later we will probably fix that, but in the
meantime consider using an ON COMMIT DELETE ROWS temp table, created
only once per connection, instead.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:38 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com