Re: About adding an attribute to a system catalog

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tanmay Deshpande <tp(dot)deshpande07(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: About adding an attribute to a system catalog
Date: 2014-03-31 16:50:02
Message-ID: CA+TgmobguHwtxNsERa==NfzRm2wBS=rNsVH=Lh+KOgq-9CzH0Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Mar 24, 2014 at 6:38 PM, Tanmay Deshpande
<tp(dot)deshpande07(at)gmail(dot)com> wrote:
> My doubt is what changes does one have to make in the source code if he/she
> is trying to add an attribute to the existing system catalogs table ?

In general, you mostly need to modify the pg_whatever.h file that
defines that system catalog, including the DATA lines which appear
there, and update the documentation in catalogs.sgml. Then you'll
want to look for places where Form_pg_whatever values are initialized
and make the appropriate changes there. For a recent example of a
relatively simple patch that did this kind of thing, see commit
6cb86143e8e1e855255edc706bce71c6ebfd9a6c.

Generally, I find that it's helpful to pick an attribute in the same
table that has properties similar to the new thing I'm adding, and
then grep for that throughout the source base. Then, I go check
whether any of those places need updating.

Adding attributes to bootstrap tables is a whole lot more fiddly than
for other system tables. I suggest looking at a patch that did this
to see what's involved. For example, commit
76a47c0e7423891d4b4f0977312f46fec6c5c416 removed and replaced a column
in pg_attribute, so by looking through there you could see all of the
places that had to be updated.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message steve k 2014-03-31 16:55:45 Re: PQputCopyData dont signal error
Previous Message David Johnston 2014-03-31 16:44:21 Re: PQputCopyData dont signal error