Re: Cannot insert a duplicate key into unique index pg_calss_oid_index

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: charette(at)writeme(dot)com (Stephane Charette)
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Cannot insert a duplicate key into unique index pg_calss_oid_index
Date: 2003-02-06 21:13:08
Message-ID: 15764.1044565988@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

charette(at)writeme(dot)com (Stephane Charette) writes:
> backend> reindex database log force
> NOTICE: relation 1247 was reindexed
> NOTICE: relation 1249 was reindexed
> ERROR: Cannot create unique index. Table contains non-unique values
> backend>

> What does this mean, and how do I fix it?

It would appear that you've actually got some duplicate rows (at least
with duplicate OIDs) in pg_class.

To find 'em, try
select oid from pg_class group by oid having count(*) > 1;
then you can do
select ctid,oid,* from pg_class where oid = <whatever>;

Assuming they are actually duplicates (everywhere except for the ctid
field), you should be able to do
delete from pg_class where ctid = '<whatever>';
to zap all but one. Then reindex.

I would advise an update to 7.2.4, which fixes one known possible cause
of duplicate rows.

If you can figure out a sequence that reproduces the problem, btw, I
would like to know about it. The known cause involves a system crash
at just the wrong time; it's not clear if your "reboots" were due to
system failure or not.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-02-06 21:15:57 Re: backend process crash - PL/pgSQL functions - parsing problem?
Previous Message Tom Lane 2003-02-06 21:07:13 Re: pg_temp schemas