pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Federico Passaro <fede@link.it>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Re: Autoincrement
Date: Mon, 20 Jul 1998 12:23:59 +0300
Message-ID: <l03110704b1d8b9225cd1@[147.233.159.109]> (raw)
In-Reply-To: <l03110702b1d8ab0b0cc8@[147.233.159.109]>

At 11:06 +0300 on 20/7/98, Federico Passaro wrote:


> When I have to pay this penalty: on insert / update / query ?

Query, I think.

> > > A more robust solution is to use a trigger. Look at the files
> > > <PostGreSQL source dir>/contrib/spi/autoinc.*
> >
> > I am not sure a solution which depends on writing code in C and having
> > postgres superuser privileges can be considered "more robust". I'd
> > recommend the use of sequences in any case.
>
> Could you explain your assertion please: the C code I mentioned is ready and
> well tested ....

As far as I understand, the autoinc trigger increments the value of the
field on both insert and update. If you want to do it only for insert
(which is what you have to do if the field is to be used as a key), you
have to change the code. That opens a can of bugs.

Besides, the warning is general. Things that appear in the contrib
directory are not actually guaranteed to be up to date - are they? The
contributors may not submit updated versions if there are any future
versions of Postgres. Thus, you may remain without a function.

The funny thing is that the autoinc trigger actually relies on the builtin
sequences, thus it is almost the same, but you rely on external code for
your, and do a lot of work you didn't want to do (create function, create
trigger).


Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





view thread (11+ messages)  latest in thread

Message-ID: <l03110704b1d8b9225cd1@[147.233.159.109]>
Permalink:  ../l03110704b1d8b9225cd1@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03110704b1d8b9225cd1@[147.233.159.109]

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: herouth@oumail.openu.ac.il, fede@link.it
  Subject: Re: [SQL] Re: Autoincrement
  In-Reply-To: <l03110704b1d8b9225cd1@[147.233.159.109]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox