ROLLBACK of DROP TABLE leaves database in inconsistent state

From: "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk>
To: pgsql-hackers(at)postgresql(dot)org
Subject: ROLLBACK of DROP TABLE leaves database in inconsistent state
Date: 2000-05-06 21:30:52
Message-ID: 200005062130.e46LUrs11742@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Of course, no one should try to rollback a DROP TABLE, but if it happens
the system tables are left in a mess, because the disk file has gone but
the system records are restored by the rollback:

[version 7.0RC2]
junk=# create table aaa (a int4);
CREATE
junk=# begin
junk-# ;
BEGIN
junk=# drop table aaa;
NOTICE: Caution: DROP TABLE cannot be rolled back, so don't abort now
DROP
junk=# rollback;
ROLLBACK
junk=# select * from aaa;
NOTICE: mdopen: couldn't open aaa: No such file or directory
NOTICE: RelationIdBuildRelation: smgropen(aaa): No such file or directory
NOTICE: mdopen: couldn't open aaa: No such file or directory
NOTICE: mdopen: couldn't open aaa: No such file or directory
NOTICE: mdopen: couldn't open aaa: No such file or directory
NOTICE: mdopen: couldn't open aaa: No such file or directory
ERROR: cannot open relation aaa
junk=# create table aaa (a int4);
ERROR: Relation 'aaa' already exists

The solution is either to exclude the system records from the rollback, or
to delay deleting the disk file until the transaction is committed.

Which is preferable?

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP key from public servers; key ID 32B8FAA1
========================================
"If it is possible, as much as it depends on you, live
peaceably with all men." Romans 12:18

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Benjamin Adida 2000-05-06 21:50:46 Re: You're on SecurityFocus.com for the cleartext passwords.
Previous Message Bruce Momjian 2000-05-06 20:34:47 Re: You're on SecurityFocus.com for the cleartext passwords.