Re: [HACKERS] SERIAL data type

From: "Billy G(dot) Allie" <Bill(dot)Allie(at)mug(dot)org>
To: t-ishii(at)sra(dot)co(dot)jp (Tatsuo Ishii)
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] SERIAL data type
Date: 1998-09-12 02:43:09
Message-ID: 199809120243.WAA25027@bgalli.mug.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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?

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

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

Of these two options, I prefer #1.

Also, should we be able to specify a starting value for the sequence when the
table is created? For example "create table t (c text, i serial(1000));" to
set the starting value of the sequence to 1000.
--
____ | Billy G. Allie | Domain....: Bill(dot)Allie(at)mug(dot)org
| /| | 7436 Hartwell | Compuserve: 76337,2061
|-/-|----- | Dearborn, MI 48126| MSN.......: B_G_Allie(at)email(dot)msn(dot)com
|/ |LLIE | (313) 582-1540 |

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Bruccoleri 1998-09-12 03:24:02 Porting effort and patches for the Irix port for PostgreSQL
Previous Message D'Arcy J.M. Cain 1998-09-12 02:14:40 Re: [HACKERS] SERIAL data type