Re: Some one deleted pg_database entry how to fix it? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Some one deleted pg_database entry how to fix it?
Date
Msg-id 25265.1079453477@sss.pgh.pa.us
Whole thread Raw
In response to Some one deleted pg_database entry how to fix it?  (Dave Cramer <pg@fastcrypt.com>)
Responses Re: Some one deleted pg_database entry how to fix it?  (Dave Cramer <pg@fastcrypt.com>)
List pgsql-hackers
Dave Cramer <pg@fastcrypt.com> writes:
> psql dbname can still connect but when I go to the pg_database table the
> db is not there as a result I cannot do a pg_dump on it? 

Hm, it doesn't make a lot of sense that fresh connections would still
succeed if the pg_database row is deleted, but ...

> I tried forcing an entry into pg_database but it won't allow me to set
> the oid ?

You don't have to; the DB OID doesn't appear anywhere within the
database (except possibly with the database comment, if you have one).

So:

* Determine the old DB OID, by elimination if necessary.

* Create a new database and determine its OID.

* Shut down postmaster.

* Blow away $PGDATA/base/NEWOID, and rename $PGDATA/base/OLDOID to be $PGDATA/base/NEWOID.

* Restart postmaster.

* Try to figure out what you did wrong, so you don't do it again...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Marty Scholes
Date:
Subject: Re: WAL write of full pages
Next
From: Bruce Momjian
Date:
Subject: Re: Custom format for pg_dumpall