Re: lost tables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Josh Goldberg" <josh(at)4dmatrix(dot)com>
Cc: "postgres-admin" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: lost tables
Date: 2003-04-01 19:54:18
Message-ID: 2682.1049226858@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

"Josh Goldberg" <josh(at)4dmatrix(dot)com> writes:
> cms3=# drop table view_log;
> NOTICE: RelationBuildDesc: can't open view_log: No such file or directory
> ERROR: cannot open view_log: No such file or directory

You should be able to get to a state where you can drop the table by
doing

touch $PGDATA/base/dbnumber/filenumber

where filenumber is the pg_class.relfilenode entry for the table (19433
here), and dbnumber is the pg_database.oid entry for the database.

If there is still a symlink in that position, either remove it and do
the touch to make a plain file, or do a touch where the symlink points
instead.

You may need to repeat for each index used by the table, if you moved
those off too.

BTW, recent versions (7.3 at least, and I think 7.2) will allow a DROP
TABLE without insisting on finding an underlying file, for example:

regression=# create table z(f1 int);
CREATE TABLE
regression=# select relfilenode from pg_class where relname = 'z';
relfilenode
-------------
2204132
(1 row)

-- as postgres, rm the file 2204132

regression=# drop table z;
WARNING: cannot unlink 2066720/2204132: No such file or directory
DROP TABLE

regards, tom lane

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Chris White 2003-04-01 20:15:37 Documentation for the \lo_export and \lo_import commands
Previous Message Robert Treat 2003-04-01 19:38:47 Re: Backup features available for postgres database