Re: How to implement an auto-increment column for a system catalog table?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: Xin Wang <andywx(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: How to implement an auto-increment column for a system catalog table?
Date: 2009-03-16 12:40:11
Message-ID: 16139.1237207211@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Simon Riggs <simon(at)2ndQuadrant(dot)com> writes:
> On Mon, 2009-03-16 at 10:18 +0800, Xin Wang wrote:
>> I am using Postgres to build the prototype in a research project. I need
>> to create a new system catalog table with an auto-increment column.

> Other catalog tables use a new oid for each new row/entry. Just do it in
> the code for adding each new entry. Look at backend/catalog/heap.c
> heap_create_with_catalog(), or something simpler like
> backend/commands/dbcommands.c createdb().

Note that in fact the bottom level heap_insert code will handle
assigning a new OID for you. The only cases where calling code needs to
do that explicitly are when the OID has to be known before creation of
the new row for some reason (usually, circular OID references).

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Gierth 2009-03-16 13:16:08 Re: hstore improvements?
Previous Message Heikki Linnakangas 2009-03-16 10:08:06 Re: Review: B-Tree emulation for GIN