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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: OID vs SERIAL? (Was: Re: [HACKERS] Sequences....)
Дата
Msg-id 19656.921723901@sss.pgh.pa.us
обсуждение исходный текст
Ответ на OID vs SERIAL? (Was: Re: [HACKERS] Sequences....)  (Clark Evans <clark.evans@manhattanproject.com>)
Ответы Re: OID vs SERIAL? (Was: Re: [HACKERS] Sequences....)  (Bruce Momjian <maillist@candle.pha.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Vadim Mikheev
Дата:
Сообщение: Re: vacuum slowness
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] Sequences....