pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Carolyn Lu Wong <carolyn@kss.net.au>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: What is happening?
Date: Thu, 03 Aug 2000 11:05:09 -0400
Message-ID: <8036.965315109@sss.pgh.pa.us> (raw)
In-Reply-To: <3988FF7C.F023BCC@kss.net.au>
References: <3988FF7C.F023BCC@kss.net.au>

Carolyn Lu Wong <carolyn@kss.net.au> writes:
> I was trying to dump data, drop then recreate table, and import data
> back to the table. There were errors during the process and the
> transaction was not committed.

> ERROR: mdopen: couldn't open accounts: No such file or directory.

Rolling back a "drop table" doesn't work at the moment :-(, because the
physical table file is deleted at the moment of DROP.  When you aborted
the transaction, the system-table rows for the table came back to life,
but the file didn't.

You can get back into a consistent state by creating a dummy table file
by hand, eg do

	touch .../data/base/yourdb/accounts

and then you will be able to do the DROP TABLE.  After that you can
recreate and reload the table from the data file (which I hope you
kept...)

One of the things on the to-do list is to postpone physical delete of
table files till COMMIT, so that a DROP can be rolled back safely.
(Not likely for 7.1, but maybe for 7.2.)  In the meantime, it's probably
best not to do DROP inside a transaction.  7.0 will emit a notice
warning you about this, but earlier versions don't.

BTW, ALTER TABLE RENAME in a transaction is equally dangerous for the
same kind of reason.

			regards, tom lane



view thread (3+ messages)

Message-ID: <8036.965315109@sss.pgh.pa.us>
Permalink:  ../8036.965315109@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8036.965315109@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, carolyn@kss.net.au
  Subject: Re: What is happening?
  In-Reply-To: <8036.965315109@sss.pgh.pa.us>
  References: <3988FF7C.F023BCC@kss.net.au> <8036.965315109@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox