pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Craig Ringer <craig.ringer@enterprisedb.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Add primary keys to system catalogs
Date: Sat, 3 Oct 2020 13:23:46 -0400
Message-ID: <20201003172346.GA9097@momjian.us> (raw)
In-Reply-To: <CAGRY4nz8dbL1OAT9X+EB1c_q_ZxJsdB-dp8csSLqCEDb1o6=Eg@mail.gmail.com>
References: <dc5f44d9-5ec1-a596-0251-dadadcdede98@2ndquadrant.com>
	<CAGRY4nz8dbL1OAT9X+EB1c_q_ZxJsdB-dp8csSLqCEDb1o6=Eg@mail.gmail.com>

On Sat, Oct  3, 2020 at 09:27:02PM +0800, Craig Ringer wrote:
> 
> 
> On Sat, 3 Oct 2020, 14:40 Peter Eisentraut, <peter.eisentraut@2ndquadrant.com>
> wrote:
> 
>     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.
> 
> 
>     Any thoughts on this direction?
> 
> 
> I like the general idea a lot. I've used Pg for a long time and I still
> struggle to march up relationships sometimes. Especially given that some things
> use relation oid oid keys and some use named cols as keys. 
> 
> So a big +1 from me for the idea. Especially if we ensure psql recognises when
> the relation 'oid' attribute has a declared PK and includes it in the column
> list. 

+1

> I don't object to simply declaring them without any implementing triggers. You
> aren't supposed to mess with the catalogs anyway. I'd actually like it to be
> defended against more actively by default. So the FKs are implicitly always
> valid, because the implementation says so. Much the same way trigger based FKs
> are unless you break the rules and mess with the triggers.
> 
> Frankly I think we really need a way to mark FKs to be DISABLED or NOT CHECKED
> or something and a way to mark them as NOT VALID. Rsther than expecting uses to
> fiddle with the implementation triggers. But I don't think FKs on system
> catalogs require that, it's just be cosmetic there.

+1

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EnterpriseDB                             https://enterprisedb.com

  The usefulness of a cup is in its emptiness, Bruce Lee






view thread (39+ messages)  latest in thread

Message-ID: <20201003172346.GA9097@momjian.us>
Permalink:  ../20201003172346.GA9097@momjian.us/
Also on:    postgresql.org/message-id/20201003172346.GA9097@momjian.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: bruce@momjian.us, craig.ringer@enterprisedb.com, peter.eisentraut@2ndquadrant.com
  Subject: Re: Add primary keys to system catalogs
  In-Reply-To: <20201003172346.GA9097@momjian.us>
  References: <dc5f44d9-5ec1-a596-0251-dadadcdede98@2ndquadrant.com> <CAGRY4nz8dbL1OAT9X+EB1c_q_ZxJsdB-dp8csSLqCEDb1o6=Eg@mail.gmail.com> <20201003172346.GA9097@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox