Tom Lane wrote:
> Joseph Shraibman <jks@selectacast.net> writes:
>
>>To reproduce:
>>create table table1 ( list text, ukey int);
>>insert into table1 values( '1', 1);
>>insert into table1 values( '2', 2);
>>insert into table1 values( '3', 3);
>>insert into table1 values( '4', 4);
>>insert into table1 values( '5', 5);
>>
>
>> SELECT list,ukey INTO temporary tqt FROM table1;
>>BEGIN;
>> DECLARE cname CURSOR FOR SELECT list, ukey FROM tqt ;
>>FETCH 10 from cname;
>>DROP TABLE tqt;
>>END;
>>
>
> I don't see an error if I do it that way, but I do see an error if the
> cursor hasn't yet fetched all the rows:
>
What version are you using? I get the error using exactly what I showed you on 7.1.3.
playpen=# create table table1 ( list text, ukey int);
CREATE
playpen=# insert into table1 values( '1', 1);
INSERT 571129 1
playpen=# insert into table1 values( '2', 2);
INSERT 571130 1
playpen=# insert into table1 values( '3', 3);
INSERT 571131 1
playpen=# insert into table1 values( '4', 4);
INSERT 571132 1
playpen=# insert into table1 values( '5', 5);
INSERT 571133 1
playpen=# SELECT list,ukey INTO temporary tqt FROM table1;
SELECT
playpen=# BEGIN;
BEGIN
playpen=# DECLARE cname CURSOR FOR SELECT list, ukey FROM tqt ;
SELECT
playpen=# FETCH 10 from cname;
list | ukey
------+------
1 | 1
2 | 2
3 | 3
4 | 4
5 | 5
(5 rows)
playpen=# DROP TABLE tqt;
NOTICE: FlushRelationBuffers(tqt, 0): block 0 is referenced (private 1, global 1)
ERROR: heap_drop_with_catalog: FlushRelationBuffers returned -2
playpen=# END;
COMMIT
playpen=#
playpen=# drop table table1;
DROP
playpen=# select version();
version
---------------------------------------------------------------------
PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled by GCC egcs-2.91.66
(1 row)
--
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio. http://www.targabot.com