Re: race conditions in my sequences

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Jeremy Hansen <jeremy(at)xxedgexx(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: race conditions in my sequences
Date: 2001-08-16 19:39:36
Message-ID: Pine.LNX.4.30.0108162137410.677-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jeremy Hansen writes:

> I have three tables, primary key, bug_id. Bug_id is a foreign key in the
> other two tables, with a cascade on update and delete.
>
> What I've done is created three sequences for each table for the bug_id.
> Sometimes the table with the primary key gets its sequence out of sync
> >from the other two tables and I start getting referential integrity
> violation problems and then all inserts start getting dropped.

What you want is one sequence that generates the primary key, and the
foreign key columns you declare as integer and fill them in manually by
reading the generated primary key for the tuple you want to reference.

--
Peter Eisentraut peter_e(at)gmx(dot)net http://funkturm.homeip.net/~peter

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Loginov 2001-08-16 19:41:03 Re[2]: Perfomance decreasing
Previous Message Gregory Wood 2001-08-16 19:09:45 Re: race conditions in my sequences