Search Postgresql Archives

Re: collision in serial numbers after INSERT?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Steve Lefevre <lefevre.10@xxxxxxx> 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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux