Re: creating "job numbers"

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: postgresql <pgsql(at)symcom(dot)com>
Cc: Jan Wieck <JanWieck(at)Yahoo(dot)com>, PgSQL-SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: creating "job numbers"
Date: 2001-03-23 18:09:49
Message-ID: 200103231809.NAA18725@jupiter.jw.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 missing because
it's transaction aborted (explicit rollback or error during
processing). The serial data type will never 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(at)Yahoo(dot)com #

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

Browse pgsql-sql by date

  From Date Subject
Next Message Roberto Mello 2001-03-23 18:53:45 Re: drop table in PL/pgSQL
Previous Message Jie Liang 2001-03-23 18:08:15 Re: SOME PL/PGSQL PROBLEMS