Re: Changing ids conflicting with serial values?

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Steven Brown <swbrown(at)ucsd(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Changing ids conflicting with serial values?
Date: 2005-11-03 03:49:22
Message-ID: 436988C2.5070207@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Steven Brown wrote:

> When I change an id (primary key serial) in a table, the next value
> returned by the sequence for the id can conflict with that id (e.g.,
> change the id to be id + 1). MySQL seems to handle this transparently
> by skipping conflicting values, but with PostgreSQL I get primary key
> conflicts. It seems rather bad if a user can modify an id in a row
> and cause failures for all future inserts - it's just too fragile.
> What's the proper way to handle this in PostgreSQL?

Why are your users modifying the key in the first place? Typically in an
environment where you have an autoincrementing key, that key is static.
Meaning it does not change for a particular
row. Thus it never conflicts. Could you perhaps explain a little further
what it is you are trying to do?

Sincerely,

Joshua D. Drake

>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend

--
The PostgreSQL Company - Command Prompt, Inc. 1.503.667.4564
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tony Caduto 2005-11-03 04:52:05 Built in function question
Previous Message Douglas McNaught 2005-11-03 03:47:20 Re: Changing ids conflicting with serial values?