Re[2]: [HACKERS] SERIAL data type

From: Sferacarta Software <sferac(at)bo(dot)nettuno(dot)it>
To: t-ishii(at)sra(dot)co(dot)jp (Tatsuo Ishii), "Billy G(dot) Allie" <Bill(dot)Allie(at)mug(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re[2]: [HACKERS] SERIAL data type
Date: 1998-09-15 11:43:13
Message-ID: 2571.980915@bo.nettuno.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello Billy,

sabato, 12 settembre 98, you wrote:

BGA> t-ishii(at)sra(dot)co(dot)jp (Tatsuo Ishii) writes:
>> A few questions for new SERIAL data type:
>> [...]
>> o explicit insertion to the serial column sets the value specified.
>> This is good. However, next implicit insertion results in that
>> previous value from the sequence + 1 is set.
>>
>> create table t (c text, i serial);
>> insert into t values('a');
>> insert into t values('b',100);
>> insert into tvalues('c');
>> select * from t;
>>
>> a 1
>> b 100
>> c 2
>>
>> This seems a little bit unnatural for me. may be i of the thrid row
>> should be 101?

BGA> The action above is definitely 'not right'. It is my opinion that either:

BGA> 1. Explicit insertion into a serial column be dis-allowed.
BGA> 2. If explicit insertion is allowed, then the sequence need to be set so
BGA> the next implicit insertsion result in the last explicit insertion
BGA> value + 1 being used (i.e. 101 instead of 2 in the example above).

BGA> Of these two options, I prefer #1.

BGA> Also, should we be able to specify a starting value for the sequence when the
BGA> table is created? For example "create table t (c text, i serial(1000));" to
BGA> set the starting value of the sequence to 1000.

I would like to remember there's another problem with sequences.
If you increment a sequence during a transaction and then the transaction
rolls back, the sequence's original value don't be restored.

Jose'

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Kalchev 1998-09-15 11:47:23 perl vs perl5
Previous Message Daniel Kalchev 1998-09-15 11:30:18 configure autodetection problem