Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oQxRU-0003v5-Bb for pgsql-general@arkaria.postgresql.org; Wed, 24 Aug 2022 20:57:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oQxRT-000202-0I for pgsql-general@arkaria.postgresql.org; Wed, 24 Aug 2022 20:57:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oQxRS-0001zn-Lx for pgsql-general@lists.postgresql.org; Wed, 24 Aug 2022 20:57:38 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oQxRM-0004Dh-AM for pgsql-general@lists.postgresql.org; Wed, 24 Aug 2022 20:57:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 27OKvVRg1161777; Wed, 24 Aug 2022 16:57:31 -0400 From: Tom Lane To: Bryn Llewellyn cc: pgsql-general list Subject: Re: Two questions about "pg_constraint" In-reply-to: <496793CE-A048-434B-ABC0-6BFC0C65C3EC@yugabyte.com> References: <496793CE-A048-434B-ABC0-6BFC0C65C3EC@yugabyte.com> Comments: In-reply-to Bryn Llewellyn message dated "Wed, 24 Aug 2022 13:11:17 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1161775.1661374651.1@sss.pgh.pa.us> Date: Wed, 24 Aug 2022 16:57:31 -0400 Message-ID: <1161776.1661374651@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Bryn Llewellyn 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