From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bryn Llewellyn <bryn@yugabyte.com>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: Two questions about "pg_constraint"
Date: Wed, 24 Aug 2022 16:57:31 -0400
Message-ID: <1161776.1661374651@sss.pgh.pa.us> (raw)
In-Reply-To: <496793CE-A048-434B-ABC0-6BFC0C65C3EC@yugabyte.com>
References: <496793CE-A048-434B-ABC0-6BFC0C65C3EC@yugabyte.com>
Bryn Llewellyn <bryn@yugabyte.com> writes:
> *Question 1: why does "pg_constraint" have a "connamespace" column?*
You appear to be assuming that every pg_constraint entry is tied to
a table. This isn't so.
(1) That catalog also carries check constraints for domains, which
are tied to types instead. Yeah, you could imagine some rule like
"look in either pg_class or pg_type to find the schema", but it'd
be really painful.
(2) The SQL standard describes "assertions", which are global
check constraints that can affect multiple tables. We don't
support those, and very possibly never will, but the pg_constraint
catalog is set up to support them. Presumably they'd be stored
with conrelid and contypid both zero, so there would be no other
place to find out the assertion's schema.
I'm not entirely convinced that putting these two (or three) sorts
of objects in the same catalog was a great design. However, that's
what we've got and changing it seems like more trouble than it'd be
worth.
regards, tom lane
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-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, bryn@yugabyte.com
Subject: Re: Two questions about "pg_constraint"
In-Reply-To: <1161776.1661374651@sss.pgh.pa.us>
References: <496793CE-A048-434B-ABC0-6BFC0C65C3EC@yugabyte.com> <1161776.1661374651@sss.pgh.pa.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