Re: lost tables - Mailing list pgsql-admin

From Tom Lane
Subject Re: lost tables
Date
Msg-id 2682.1049226858@sss.pgh.pa.us
Whole thread Raw
In response to Re: lost tables  ("Josh Goldberg" <josh@4dmatrix.com>)
Responses Documentation for the \lo_export and \lo_import commands
List pgsql-admin
"Josh Goldberg" <josh@4dmatrix.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


pgsql-admin by date:

Previous
From: Robert Treat
Date:
Subject: Re: Backup features available for postgres database
Next
From: "Chris White"
Date:
Subject: Documentation for the \lo_export and \lo_import commands