Re: Adding a new table to the system catalog

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Paul Howells <paul(dot)steven(dot)howells(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Adding a new table to the system catalog
Date: 2018-05-26 16:54:45
Message-ID: 7320.1527353685@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Paul Howells <paul(dot)steven(dot)howells(at)gmail(dot)com> writes:
> I am exploring and poking at the source code to inform a design for adding
> valid-time support to postgres. The feature will required updating
> existing system catalog tables as well as adding one or more new tables.

> Is there any documentation on how to update the system catalog? What files
> need to be created/updated? Do I need to run any utilities for generation
> manually or is this done as part of the build? How do I assign a new OID?

The traditional advice for this is to look at past patches that added new
catalogs. Recent examples that look pretty small otherwise include commit
1753b1b02 ("Add pg_sequence system catalog") and commit 6c268df12 ("Add
new catalog called pg_init_privs"). Also look at patches that just added
a column to an existing catalog, since it sounds like you need to do that
too; perhaps 039eb6e92 ("Logical replication support for TRUNCATE").

However, if you're doing this against HEAD, as you should be if you harbor
any hopes of getting a patch accepted in the future, you need to be aware
that we just made drastic changes in the way we represent initial catalog
data (i.e., entries inserted during bootstrap). The old way with DATA
lines in the catalog/*.h files is gone in favor of *.dat files. The good
news is that it's better documented than before, and we got rid of some of
the more tedious manual steps like creating Anum_foo macros. See

https://www.postgresql.org/docs/devel/static/bki.html

and be sure to study the current contents of the catalog/*.h files
rather than what was there up to a couple months ago.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Gierth 2018-05-26 19:22:43 Re: SPI/backend equivalent of extended-query Describe(statement)?
Previous Message Tom Lane 2018-05-26 16:21:33 Re: Allowing printf("%m") only where it actually works