Add primary keys to system catalogs

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Add primary keys to system catalogs
Date: 2020-10-03 06:40:31
Message-ID: dc5f44d9-5ec1-a596-0251-dadadcdede98@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I saw someone ask once for a schema diagram of the system catalogs.
Things like that have occasionally been produced manually, but they are
not regularly updated. That made me wonder, why can't we add primary
and foreign keys to system catalogs and then have existing tools produce
such a schema diagram automatically?

Since we have ADD PRIMARY KEY USING INDEX, we can declare a primary key
for an existing index. So this doesn't have to affect the low-level
early bootstrapping. The attached patch adds those commands manually.
Another option might be to have the catalog generation Perl tooling
create those declarations automatically from some marker in the catalog
files. That would also allow declaring unique constraints for the
unique indexes that don't end up being the primary key.

I'm not dealing here with how we might do foreign keys between system
catalogs, but I think the idea would be to have some way to declare a
foreign key "on paper" without any actual triggers.

Any thoughts on this direction?

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
0001-Add-primary-keys-to-system-catalogs.patch text/plain 9.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kuntal Ghosh 2020-10-03 07:28:01 Re: Incorrect assumption in heap_prepare_freeze_tuple
Previous Message Jürgen Purtz 2020-10-03 04:59:39 Re: [PATCH] Add section headings to index types doc