From: | Bill Moran <wmoran(at)potentialtech(dot)com> |
---|---|
To: | Steve Lefevre <lefevre(dot)10(at)osu(dot)edu> |
Cc: | lawpoop(at)gmail(dot)com, pgsql-general(at)postgresql(dot)org |
Subject: | Re: collision in serial numbers after INSERT? |
Date: | 2007-06-03 22:08:01 |
Message-ID: | 20070603180801.b4f608fe.wmoran@potentialtech.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Steve Lefevre <lefevre(dot)10(at)osu(dot)edu> wrote:
>
> Bill Moran wrote:
> > Don't do that. Please let us know what site recommended that so I can
> > send an email to the author correcting them.
> >
> Hello Bill -
>
> The 'offending' site and article is at
> http://www.sitepoint.com/article/site-mysql-postgresql-2/3
My goodness, that article is ancient. 2001. I have a hard time
believing he's going to update it if it's been wrong that long.
> > Instead, do SELECT currval('<seqname>'), which is guaranteed to be isolated
> > from other sessions.
> >
> I've also gotten other advice to SELECT next_val ( whatever the exact
> wording is) will reserve that serial number for you. Is that true?
Yes, please see the documentation. Both currval() and next_val() are
transaction safe (thus guaranteed not to cause overlapped serials) but
they do slightly different things.
--
Bill Moran
http://www.potentialtech.com
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Davis | 2007-06-03 22:10:27 | Re: multimaster |
Previous Message | Michael Glaesemann | 2007-06-03 22:06:22 | Re: Multiple customers sharing one database? |