Re: OID vs SERIAL? (Was: Re: [HACKERS] Sequences....)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Clark Evans <clark(dot)evans(at)manhattanproject(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: OID vs SERIAL? (Was: Re: [HACKERS] Sequences....)
Date: 1999-03-18 02:25:01
Message-ID: 19656.921723901@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Clark Evans <clark(dot)evans(at)manhattanproject(dot)com> writes:
> Sorry for the igorance, but I'm not quite
> understanding. Assuming a new SERIAL type
> is made. What would be the difference
> between the new type and an OID?

The new type would have an identifying OID, namely the OID assigned
to its row in pg_type. This OID would be the data type indicator for
all SERIAL columns.

However, for each SERIAL column there would need to be a sequence
object, and this sequence object would have its *own* unique OID
(the OID assigned to its row in pg_class, IIRC).

To manipulate a SERIAL column you need to be able to look up the OID
of its sequence, so that you can do things to the sequence. I suggested
that storing a copy of the sequence's OID in the column's atttypmod
field would be worthwhile, because it could be accessed directly when
working on the table containing the SERIAL column, without having to do
a lookup in a system table.

I think it'd still be a good idea to have a system table containing the
mapping from SERIAL columns to (OIDs of) their associated sequences.
The atttypmod idea is just a trick to bypass having to do lookups in
this table for the most common operations on a SERIAL column.

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-03-18 02:33:51 Re: [HACKERS] Sequences....
Previous Message Vadim Mikheev 1999-03-18 01:53:41 Re: vacuum slowness