Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wyVZv-003RAs-2g for pgsql-general@arkaria.postgresql.org; Mon, 24 Aug 2026 14:23:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wyVZu-002wqJ-1A for pgsql-general@arkaria.postgresql.org; Mon, 24 Aug 2026 14:23:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wyVZu-002wqA-02 for pgsql-general@lists.postgresql.org; Mon, 24 Aug 2026 14:23:10 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wyVZr-00000002C7R-0sCF for pgsql-general@lists.postgresql.org; Mon, 24 Aug 2026 14:23:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 67OEN1Fh326994; Mon, 24 Aug 2026 10:23:01 -0400 From: Tom Lane To: Xavier Tarifa cc: pgsql-general@lists.postgresql.org Subject: Re: information_schema.constraint_column_usage view missing info In-reply-to: References: Comments: In-reply-to Xavier Tarifa message dated "Mon, 24 Aug 2026 08:44:13 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <326992.1787581381.1@sss.pgh.pa.us> Date: Mon, 24 Aug 2026 10:23:01 -0400 Message-ID: <326993.1787581381@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Xavier Tarifa writes: > how do you go about finding information about constraint columns? I > was trying to use the view information_schema.constraint_column_usage > but I've found out that to uniquely identify a constraint it would > need to show the constraint table, but in case of foreign keys it only > shows the table of the referenced column. Yeah. The back story here is that the SQL standard says that constraint names are to be unique per-schema. So they defined information_schema.constraint_column_usage on the assumption that constraint_schema + constraint_name is a unique identifier. Postgres of course considers constraint names to be local to a table, so that different tables in the same schema can use the same constraint name. So you can either design your app to obey the spec's restriction, or use something other than constraint_column_usage to get info about your constraints. Neither end of this is likely to change. We're not going to extend constraint_column_usage with extra columns: the entire point of information_schema is to present an exactly standards-compliant view of the catalogs. And we're not going to require constraint names to be unique per-schema either; even if we wanted to do that, it'd doubtless break too many existing applications. regards, tom lane