Re: Postgres db corrupted ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: valen(at)tuatha(dot)org
Cc: postgres <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Postgres db corrupted ?
Date: 2003-07-29 16:55:04
Message-ID: 29907.1059497704@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

"John P. Looney" <valen(at)tuatha(dot)org> writes:
>> If no go, could we see the output of "select * from pg_database"?

> Yep, no worries...

> postgres=# select * from pg_database;
> datname | datdba | encoding | datistemplate | datallowconn | datlastsysoid | datvacuumxid | datfrozenxid | datpath
> -----------------+--------+----------+---------------+--------------+---------------+--------------+--------------+---------
> bbadmin | | 0 | f | t | 16554 | 49 | 49 |

Hm, that datdba field actually is NULL, isn't it? That's what you need
to fix. The low-level code isn't expecting it to be NULL, and falls
over in surprising ways. (Recent releases try to enforce NOT NULL on
system catalog columns that mustn't be NULL, but I'm not sure how
bulletproof that really is.)

I'd try

UPDATE pg_database SET datdba = <something reasonable> WHERE datdba IS NULL;

You could just set them all to 1 (the postgres userid); if you want
these databases owned by specific users then see pg_shadow.usesysid for
the numbers to insert.

Once you have all the entries fixed, do the "VACUUM FULL pg_database"
fandango for good luck, and you should be back in business.

regards, tom lane

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Benjamin Thelen (CCGIS) 2003-07-29 16:56:01 changing ownership of db
Previous Message John P. Looney 2003-07-29 16:22:56 Re: Postgres db corrupted ?