Re: [GENERAL] please help me recover from duplicate key in unique index
От | Bruce Momjian |
---|---|
Тема | Re: [GENERAL] please help me recover from duplicate key in unique index |
Дата | |
Msg-id | 200001042347.SAA00530@candle.pha.pa.us обсуждение исходный текст |
Ответ на | please help me recover from duplicate key in unique index (Charles Martin <martin_pgsql@yahoo.com>) |
Ответы |
Re: [GENERAL] please help me recover from duplicate key in unique index
|
Список | pgsql-general |
Try: SELECT oid, * FROM table GROUP BY oid HAVING count(*) > 1 that should show your duplicates, and you can remove them using table.oid = _bad_number_. > Please help me recover our database from what I think > is a duplicate key in unique index problem. > > We have a table of the following form: > > create table foo (id serial primary key, x > integer) > > in our code we had, outside of any BEGIN/COMMIT block: > > insert into foo (x) values (...) > > Without the transaction block, I believe we have had > duplicate keys inserted. I've fixed the bug in the > code, but now I need to fix the database! > > When I try to vacuum, I get this: > > > vacuum; > NOTICE: Rel sessions: TID 5/2: OID IS INVALID. > TUPGONE 1. > NOTICE: Rel sessions: TID 5/6: OID IS INVALID. > TUPGONE 1. > NOTICE: Rel sessions: TID 13/2: OID IS INVALID. > TUPGONE 1. > NOTICE: Rel sessions: TID 13/6: OID IS INVALID. > TUPGONE 1. > ERROR: Cannot insert a duplicate key into a unique > index > > When I try to dump it out (to manually repair it), I > get this: > > $ pg_dump gtmd000103 > gtmd.1 > pqWait() -- connection not open > PQendcopy: resetting connection > SQL query to dump the contents of Table 'content' did > not execute correctly. After we read all the table > contents from the backend, PQendcopy() failed. > Explanation from backend: 'pqWait() -- connection not > open > '. > The query was: 'COPY "content" TO stdout; > '. > > Can anybody help me? I am desperate. Thanks. > > Charles > > __________________________________________________ > Do You Yahoo!? > Talk to your friends online with Yahoo! Messenger. > http://messenger.yahoo.com > > ************ > > -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
В списке pgsql-general по дате отправления: