bug w/ cursors and savepoints

From: Neil Conway <neilc(at)samurai(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: bug w/ cursors and savepoints
Date: 2005-01-25 03:54:50
Message-ID: 1106625290.1780.101.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Someone at Fujitsu pointed out the following bug in 8.0:

begin;
savepoint x;
create table abc (a int);
insert into abc values (5);
declare foo cursor for select * from abc;
rollback to x;
fetch from foo; -- hits an Assert()
commit;

The stacktrace is:

#2 0x0826367b in ExceptionalCondition (conditionName=0x8316544
"!(((bool)((relation)->rd_refcnt == 0)))",
errorType=0x8316004 "FailedAssertion", fileName=0x8315f08
"/home/neilc/pgsql/src/backend/utils/cache/relcache.c", lineNumber=2118)
at /home/neilc/pgsql/src/backend/utils/error/assert.c:51
#3 0x0825cec0 in AtEOSubXact_RelationCache (isCommit=0 '\0', mySubid=2,
parentSubid=1)
at /home/neilc/pgsql/src/backend/utils/cache/relcache.c:2118
#4 0x080ade30 in AbortSubTransaction ()
at /home/neilc/pgsql/src/backend/access/transam/xact.c:3407
#5 0x080ac404 in CommitTransactionCommand ()
at /home/neilc/pgsql/src/backend/access/transam/xact.c:1982
#6 0x081de4ba in finish_xact_command ()
at /home/neilc/pgsql/src/backend/tcop/postgres.c:1843
#7 0x081dd102 in exec_simple_query (query_string=0x83b6ad4 "rollback to
x;") at /home/neilc/pgsql/src/backend/tcop/postgres.c:950

So what's happening is that the cursor still holds a reference to the
newly-created table, so we can't just blow it away. I don't know the
subtransaction code too well, so I'm not sure of the right fix.
Comments?

-Neil

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim C. Nasby 2005-01-25 04:40:40 Re: userlock changes for 8.1/8.2
Previous Message David Fetter 2005-01-25 03:49:54 Re: Shortcut for defining triggers