Re: OID vs SERIAL? (Was: Re: [HACKERS] Sequences....) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: OID vs SERIAL? (Was: Re: [HACKERS] Sequences....)
Date
Msg-id 19656.921723901@sss.pgh.pa.us
Whole thread Raw
In response to OID vs SERIAL? (Was: Re: [HACKERS] Sequences....)  (Clark Evans <clark.evans@manhattanproject.com>)
Responses Re: OID vs SERIAL? (Was: Re: [HACKERS] Sequences....)
List pgsql-hackers
Clark Evans <clark.evans@manhattanproject.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


pgsql-hackers by date:

Previous
From: Vadim Mikheev
Date:
Subject: Re: vacuum slowness
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Sequences....