Re: Better alternative for Primary Key then serial?? - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: Better alternative for Primary Key then serial??
Date
Msg-id 20071212204445.GM7925@alvh.no-ip.org
Whole thread Raw
In response to Re: Better alternative for Primary Key then serial??  (pilzner <belisarius23@yahoo.com>)
List 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/)

pgsql-general by date:

Previous
From: Steve Crawford
Date:
Subject: Re: Altering field passed as parameter to plpgsql trigger
Next
From: "Daniel Verite"
Date:
Subject: Re: what is the date format in binary query results