Re: [HACKERS] Primary key requires SERIAL

From: Don Baccus <dhogaza(at)pacifier(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [HACKERS] Primary key requires SERIAL
Date: 1999-11-19 04:43:53
Message-ID: 3.0.1.32.19991118204353.00f1e7a0@mail.pacifier.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At 11:19 PM 11/18/99 -0500, Bruce Momjian wrote:
>> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
>> > We currently only allow the words PRIMARY KEY on a SERIAL column.
>>
>> Say what? There are ColConstraintElem and ConstraintElem productions
>> for PRIMARY KEY ... are they broken?
>>
>> regards, tom lane
>>
>
>Oh, I see it now. The grammer seems to only support it in SERIAL, but I
>see it works now. I guess i am surprised SERIAL PRIMARY creates the
>index and sequence, while INTEGER PRIMARY only creates the index.

Oops, I guess I blew it by responding to a post by Bruce assuming he
was right.

Postgres supports a quasi-serial type by creating an index and
sequence (while Sybase supports it more transparently)

Postgres REALLY supports sequences much like Oracle (and others?
I don't know, my DB knowledge is very sketchy). In Oracle, if
you define a primary key of type integer and want to sequence
it, you define a sequence and use "sequence_name.nextval" and
"sequence_name.currval". This is very much like "nextval" and
"currval" in Postgres, and I presume no accident.

And in Oracle you create the sequence by hand - just like you do
in Postgres.

Personally, I think maintaining an "Oracle-ish" framework is wise,
for the simple selfish reason that I'm interested in porting
Oracle-dependent SQL to Postgres.

If being "Oracle-ish" is still a goal (it was once a goal of at
least some of the implementors, it's obvious) then generating
the sequence just makes porting more difficult.

Actually, I think the inclusion of "serial" as a more integrated
type and leaving primary key stuff alone for existing types is
what makes sense. You could provide a higher level of Sybase
portability without messing up us Oracle-derived folk.

- Don Baccus, Portland OR <dhogaza(at)pacifier(dot)com>
Nature photos, on-line guides, Pacific Northwest
Rare Bird Alert Service and other goodies at
http://donb.photo.net.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-11-19 04:48:00 Re: [HACKERS] psql & regress tests
Previous Message Bruce Momjian 1999-11-19 04:36:58 Re: [HACKERS] psql & regress tests