Re: creating "job numbers" - Mailing list pgsql-sql

From Jan Wieck
Subject Re: creating "job numbers"
Date
Msg-id 200103231809.NAA18725@jupiter.jw.home
Whole thread Raw
In response to creating "job numbers"  ("postgresql" <pgsql@symcom.com>)
List pgsql-sql
postgresql wrote:
> Jan,
>
> Thanks, I must be missing something here. Bear with me, I am
> trying to form an intelligent question.
>
> Using the serial data type... I don't understand when the backend
> would skip a number.
> If the db is assigning the number with the insert, then if two (or
> more) clients are trying to insert into the db at the exact same time,
> only those that are successful should get a number. I am trying to
> envision a situation where two clients hit at the same time and
> because of problem with the insert, one aborts and the serial data
> number is skipped. I would have assumed that the aborted insert is
> just skipped no harm done.
   Concurrency  will  not cause your transactions to abort. It's   just if you do
       BEGIN;       INSERT INTO ...       ROLLBACK;
   that the generated sequence numbers don't get rolled back. So   you might find job numbers 1, 2, 4 where 3 is
missingbecause   it's transaction aborted (explicit rollback or  error  during   processing).  The  serial  data type
willnever fill in those   gaps.
 


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



pgsql-sql by date:

Previous
From: Jie Liang
Date:
Subject: Re: drop table in PL/pgSQL
Next
From: Jie Liang
Date:
Subject: Re: SOME PL/PGSQL PROBLEMS