Re: Duplicated IDs

From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Duplicated IDs
Date: 2014-08-12 18:44:30
Message-ID: 1407869070519-5814615.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alexis Bernard wrote
> Hi,
>
> I am having regurlarly duplicated rows with the same primary key.
>
> => select id, created_at, updated_at from tracks where created_at =
> '2014-07-03 15:09:16.336488';
> id | created_at | updated_at
> --------+----------------------------+----------------------------
> 331804 | 2014-07-03 15:09:16.336488 | 2014-07-03 15:37:55.253729
> 331804 | 2014-07-03 15:09:16.336488 | 2014-07-03 15:37:55.253801
>
> => select id from tracks where id = 331804;
> id
> ----
> (0 rows)
>
> => delete from tracks where created_at = '2014-07-03 15:09:16.336488' and
> updated_at = '2014-07-03 15:37:55.253801';
> ERROR: update or delete on table "tracks" violates foreign key constraint
> "fk_sources_on_track_id" on table "sources"
> DETAIL: Key (id)=(331804) is still referenced from table "sources".
>
> All colums are identical except the updated_at.
>
> PostgreSQL version is 9.3 and fsync is true.
>
> Any idea how I can clean my table? And then how I can stop this?
>
> Cheers,
> Alexis

What happens if you try and delete the older row instead of the newer one?

How does "updated_at" get populated/changed?

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Duplicated-IDs-tp5814311p5814615.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2014-08-12 19:13:51 Re: pgcluu
Previous Message Soni M 2014-08-12 18:35:29 Re: Postgresql 9.3 tuning advice