Re: race conditions in my sequences - Mailing list pgsql-general

From Peter Eisentraut
Subject Re: race conditions in my sequences
Date
Msg-id Pine.LNX.4.30.0108162137410.677-100000@peter.localdomain
Whole thread Raw
In response to race conditions in my sequences  (Jeremy Hansen <jeremy@xxedgexx.com>)
List 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@gmx.net   http://funkturm.homeip.net/~peter


pgsql-general by date:

Previous
From: Tigran
Date:
Subject: Win2K install
Next
From: Alexander Loginov
Date:
Subject: Re[2]: Perfomance decreasing