Re: Two questions about "pg_constraint"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
Cc: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Two questions about "pg_constraint"
Date: 2022-08-24 20:57:31
Message-ID: 1161776.1661374651@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bryn Llewellyn <bryn(at)yugabyte(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Hillary Masha 2022-08-24 21:01:14 Re: Corrupted Postgresql Microsoft Binaries
Previous Message Bryn Llewellyn 2022-08-24 20:43:03 Re: Two questions about "pg_constraint"