X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D472FD6D29 for ; Fri, 11 Nov 2005 16:44:54 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47238-03 for ; Fri, 11 Nov 2005 20:44:51 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by svr1.postgresql.org (Postfix) with ESMTP id 9414AD9DC2 for ; Fri, 11 Nov 2005 16:44:50 -0400 (AST) Received: from chilco.textdrive.com (chilco.textdrive.com [207.7.108.242]) by svr2.postgresql.org (Postfix) with ESMTP id 94ADFF122D for ; Fri, 11 Nov 2005 20:44:51 +0000 (GMT) Received: from [192.168.15.103] (pcp0012204803pcs.blairblvd.tn.nash.comcast.net [69.245.49.69]) by chilco.textdrive.com (Postfix) with ESMTP id 733E9DB061; Fri, 11 Nov 2005 20:44:57 +0000 (UTC) In-Reply-To: <4CA3BE1415A8974CA9E265266825EAEC08B607@DARTHVADER.nar.local> References: <4CA3BE1415A8974CA9E265266825EAEC08B607@DARTHVADER.nar.local> Mime-Version: 1.0 (Apple Message framework v746.2) Content-Type: multipart/alternative; boundary=Apple-Mail-85-963345542 Message-Id: Cc: pgsql-admin@postgresql.org From: "Thomas F. O'Connell" Subject: Re: Could not create unique index, table contains duplicated values Date: Fri, 11 Nov 2005 14:44:44 -0600 To: Martin Schievink X-Mailer: Apple Mail (2.746.2) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.015 required=5 tests=[AWL=0.014, HTML_MESSAGE=0.001] X-Spam-Score: 0.015 X-Spam-Level: X-Archive-Number: 200511/144 X-Sequence-Number: 19517 --Apple-Mail-85-963345542 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed On Nov 8, 2005, at 3:07 AM, Martin Schievink wrote: > We=92re having problems restoring a database, we dumped and tried to =20= > restore on the same databaseserver., and used the command: > > > > pg_dump -Ft -b {dbname} > {filename} > > > > to dump the database and > > > > pg_restore -d {dbname} {filename} > > > > to restore the database. At some point we=92re getting these error =20 > messages: > > > > pg_restore: [archiver (db)] Error while PROCESSING TOC: > > pg_restore: [archiver (db)] Error from TOC entry 3005; 16386 =20 > 1728253 CONSTRAINT _afdeling_id_pkey win > > pg_restore: [archiver (db)] could not execute query: ERROR: could =20 > not create unique index > > DETAIL: Table contains duplicated values. > > Command was: > > > > ALTER TABLE ONLY _afdeling_id > > ADD CONSTRAINT _afdeling_id_pkey PRIMARY KEY (id); > > pg_restore: [archiver (db)] could not execute query: ERROR: =20 > relation "public._afdeling_id_pkey" does not exist > > Command was: ALTER INDEX public._afdeling_id_pkey OWNER TO win; > > pg_restore: [archiver (db)] Error from TOC entry 3107; 16386 =20 > 1728349 CONSTRAINT _bezitting_id_pkey win > > pg_restore: [archiver (db)] could not execute query: ERROR: could =20 > not create unique index > > DETAIL: Table contains duplicated values. > > Command was: ALTER TABLE ONLY _bezitting_id > > ADD CONSTRAINT _bezitting_id_pkey PRIMARY KEY (id); > > pg_restore: [archiver (db)] could not execute query: ERROR: =20 > relation "public._bezitting_id_pkey" does not exist > > Command was: ALTER INDEX public._bezitting_id_pkey OWNER TO win; > > pg_restore: [archiver (db)] Error from TOC entry 3095; 16386 =20 > 1728337 CONSTRAINT _bezittingtype_id_pkey win > > pg_restore: [archiver (db)] could not execute query: ERROR: could =20 > not create unique index > > DETAIL: Table contains duplicated values. > > Command was: ALTER TABLE ONLY _bezittingtype_id > > ADD CONSTRAINT _bezittingtype_id_pkey PRIMARY KEY (id); > > pg_restore: [archiver (db)] could not execute query: ERROR: =20 > relation "public._bezittingtype_id_pkey" does not exist > > Command was: ALTER INDEX public._bezittingtype_id_pkey OWNER TO =20= > win; > > pg_restore: [archiver (db)] Error from TOC entry 3101; 16386 =20 > 1728343 CONSTRAINT _bezittingtypeoptie_id_pkey win > > pg_restore: [archiver (db)] could not execute query: ERROR: could =20 > not create unique index > > DETAIL: Table contains duplicated values. > > Command was: ALTER TABLE ONLY _bezittingtypeoptie_id > > ADD CONSTRAINT _bezittingtypeoptie_id_pkey PRIMARY KEY (id); > > > > We focused on the first error first, we hoped by fixing it to be =20 > able to fix the rest to (there are lots more of these errors, I =20 > just showed the first few). We tried to look for duplicates with: > > > > select id from _afdeling_id group by id having count(id) > 1; > > > > This returned 0 rows. We tried reindexing and the reindexing worked =20= > fine, which shouldn=92t work if there are duplicated values, right?. =20= > We searched for an answer and found something about the lc_ctype, =20 > we checked it and ours is on =93C=94. That seems to be right, or do we = =20 > need to check the strcoll() lc_ctype? > > > > Now we=92re actually out of ideas how to solve this issue, any help =20= > solving this issue would be greatly appreciated. Can you post some more information relevant to the issue? The =20 relevant schemas for the table and any related index defintions =20 (including primary keys). -- Thomas F. O'Connell Database Architecture and Programming Co-Founder Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-469-5150 615-469-5151 (fax)= --Apple-Mail-85-963345542 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=WINDOWS-1252
On Nov 8, 2005, at = 3:07 AM, Martin Schievink wrote:

We=92re having problems restoring a database, = we dumped and tried to restore on the same databaseserver., and used the = command:

=A0

pg_dump -Ft -b {dbname} = > {filename}

=A0

to dump the database and =

=A0

pg_restore -d {dbname}=A0 = {filename}

=A0

to restore the database. = At some point we=92re getting these error = messages:

=A0

pg_restore: [archiver = (db)] Error while PROCESSING TOC:

pg_restore: [archiver = (db)] Error from TOC entry 3005; 16386 1728253 CONSTRAINT = _afdeling_id_pkey win

pg_restore: [archiver = (db)] could not execute query: ERROR:=A0 could not create unique = index

DETAIL:=A0 Table contains duplicated = values.

=A0=A0=A0 Command = was:

=A0

ALTER TABLE ONLY = _afdeling_id

=A0=A0=A0 ADD CONSTRAINT _afdeling_id_pkey = PRIMARY KEY (id);

pg_restore: [archiver (db)] could not execute = query: ERROR:=A0 relation "public._afdeling_id_pkey" does not = exist

=A0=A0=A0 Command was: ALTER INDEX = public._afdeling_id_pkey OWNER TO win;

pg_restore: [archiver = (db)] Error from TOC entry 3107; 16386 1728349 CONSTRAINT = _bezitting_id_pkey win

pg_restore: [archiver = (db)] could not execute query: ERROR:=A0 could not create unique = index

DETAIL:=A0 Table contains duplicated = values.

=A0=A0=A0 Command was: ALTER TABLE ONLY = _bezitting_id

=A0=A0=A0 ADD CONSTRAINT _bezitting_id_pkey = PRIMARY KEY (id);

pg_restore: [archiver (db)] could not execute = query: ERROR:=A0 relation "public._bezitting_id_pkey" does not = exist

=A0=A0=A0 Command was: ALTER INDEX = public._bezitting_id_pkey OWNER TO win;

pg_restore: [archiver = (db)] Error from TOC entry 3095; 16386 1728337 CONSTRAINT = _bezittingtype_id_pkey win

pg_restore: [archiver = (db)] could not execute query: ERROR:=A0 could not create unique = index

DETAIL:=A0 Table contains duplicated = values.

=A0=A0=A0 Command was: ALTER TABLE ONLY = _bezittingtype_id

=A0=A0=A0 ADD CONSTRAINT = _bezittingtype_id_pkey PRIMARY KEY (id);

pg_restore: [archiver = (db)] could not execute query: ERROR:=A0 relation = "public._bezittingtype_id_pkey" does not = exist

=A0=A0=A0 Command was: ALTER INDEX = public._bezittingtype_id_pkey OWNER TO = win;

pg_restore: [archiver (db)] Error from TOC = entry 3101; 16386 1728343 CONSTRAINT _bezittingtypeoptie_id_pkey = win

pg_restore: [archiver (db)] could not execute = query: ERROR:=A0 could not create unique = index

DETAIL:=A0 Table contains duplicated = values.

=A0=A0=A0 Command was: ALTER TABLE ONLY = _bezittingtypeoptie_id

=A0=A0=A0 ADD CONSTRAINT = _bezittingtypeoptie_id_pkey PRIMARY KEY = (id);

=A0

We focused on the first = error first, we hoped by fixing it to be able to fix the rest to (there = are lots more of these errors, I just showed the first few). We tried to = look for duplicates with:

=A0

select id from = _afdeling_id group by id having count(id) > = 1;

=A0

This returned 0 rows. We = tried reindexing and the reindexing worked fine, which shouldn=92t work = if there are duplicated values, right?. We searched for an answer and = found something about the lc_ctype, we checked it and ours is on =93C=94. = That seems to be right, or do we need to check the strcoll() = lc_ctype?

=A0

Now we=92re actually out = of ideas how to solve this issue, any help solving this issue would be = greatly = appreciated.


Can you = post some more information relevant to the issue? The relevant schemas = for the table and any related index defintions (including primary = keys).

--
Thomas F. = O'Connell
Database Architecture and = Programming
Co-Founder
Sitening, = LLC

11= 0 30th Avenue North, Suite 6
Nashville, TN = 37203-6320
615-469-5150
615-469-5151 = (fax)
= --Apple-Mail-85-963345542--