Re: Can't pg_dumpall, claims database exists twice - Mailing list pgsql-general

From Tom Lane
Subject Re: Can't pg_dumpall, claims database exists twice
Date
Msg-id 455.1112030521@sss.pgh.pa.us
Whole thread Raw
In response to Re: Can't pg_dumpall, claims database exists twice  (Scott Ribe <scott_ribe@killerbytes.com>)
Responses Re: Can't pg_dumpall, claims database exists twice
Re: Can't pg_dumpall, claims database exists twice
List pgsql-general
Scott Ribe <scott_ribe@killerbytes.com> writes:
>> select ctid,oid,xmin,cmin,xmax,cmax,* from pg_database
>  ctid  |  oid   |  xmin  | cmin | xmax | cmax |  datname  | datdba |
> encoding | datistemplate | datallowconn | datlastsysoid | datvacuumxid |
> datfrozenxid | dattablespace | datconfig |         datacl
> -------+--------+--------+------+------+------+-----------+--------+--------
> --+---------------+--------------+---------------+--------------+-----------
> ---+---------------+-----------+------------------------
>  (0,1) | 288848 | 787399 |    0 |    0 |    0 | pedcard   |      1 |
> 0 | f             | t            |         17228 |          482 |
> 482 |          1663 |           |
>  (0,3) | 220622 |   3149 |    0 |    0 |    0 | pedcard   |      1 |
> 0 | f             | t            |         17228 |       770122 |
> 3221995595 |          1663 |           |

Now how the heck did that happen?  That's not some kind of weird UPDATE
failure, because the rows have different OIDs ... it seems like the
newer row must have been explicitly inserted, and it should surely have
been blocked by the unique index on datname.  Are there subdirectories
under $PGDATA/base for both of those OIDs?

If so, I'd suggest renaming one DB or the other by brute force, eg
    update pg_database set datname = 'pedcard2' where oid = 288848;
    checkpoint;
and then looking to see what you've got.  It's not obvious which of
these you want to keep.

            regards, tom lane

pgsql-general by date:

Previous
From: Scott Ribe
Date:
Subject: Re: Can't pg_dumpall, claims database exists twice
Next
From: Yudie Gunawan
Date:
Subject: Table partition for very large table