Re: Better alternative for Primary Key then serial??

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pilzner <belisarius23(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Better alternative for Primary Key then serial??
Date: 2007-12-12 20:44:45
Message-ID: 20071212204445.GM7925@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

pilzner wrote:
>
>
>
> Alvaro Herrera-3 wrote:
> >
> > Just do not update the ID -- what use do you have for that
> > anyway? If you want to prevent it, you can put a trigger to the column,
> > but IMHO it would be a waste of your time and machine resources.
> >
>
> I have absolutely no use to update the ID. I'm not sure why anyone ever
> would, and I guess I was a little shocked to find that PostGres even allows
> it.

Oh, I see. Fact is, Postgres defines it like a plain integer column and
attaches a DEFAULT clause. That's it. There's no magic to prevent it
from being modified.

The SQL standard specifies a strange beast called GENERATED BY which has
all sorts of funny behaviors, one of which is what you describe. There
have been attempts at implementing the semantics described be the spec,
but they are so contorted that so far there hasn't been definitive
success. It is expected that in the next release (8.4) something will
get done about it.

--
Alvaro Herrera http://www.advogato.org/person/alvherre
"How strange it is to find the words "Perl" and "saner" in such close
proximity, with no apparent sense of irony. I doubt that Larry himself
could have managed it." (ncm, http://lwn.net/Articles/174769/)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Verite 2007-12-12 20:58:10 Re: what is the date format in binary query results
Previous Message Steve Crawford 2007-12-12 20:39:17 Re: Altering field passed as parameter to plpgsql trigger