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 1otLgi-0001pC-3d for pgsql-general@arkaria.postgresql.org; Fri, 11 Nov 2022 04:30:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1otLgg-0002mr-B4 for pgsql-general@arkaria.postgresql.org; Fri, 11 Nov 2022 04:30:42 +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 1otLgg-0002mi-0Y for pgsql-general@lists.postgresql.org; Fri, 11 Nov 2022 04:30:42 +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 1otLgY-0001H3-1E for pgsql-general@postgresql.org; Fri, 11 Nov 2022 04:30:40 +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 2AB4UWQ4457234; Thu, 10 Nov 2022 23:30:32 -0500 From: Tom Lane To: Konstantin Izmailov cc: "pgsql-general@postgresql.org" Subject: Re: programmatically retrieve details of a custom Postgres type In-reply-to: <454980.1668139813@sss.pgh.pa.us> References: <454980.1668139813@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Thu, 10 Nov 2022 23:10:13 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <457232.1668141032.1@sss.pgh.pa.us> Date: Thu, 10 Nov 2022 23:30:32 -0500 Message-ID: <457233.1668141032@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > For a composite type, pg_type.typrelid links to pg_class and pg_attribute > entries that work much like a table. Actually, you could reverse that: for a table, pg_type.typrelid links to pg_class and pg_attribute entries that work much like a composite type. For both relations and composite types, there are pg_class and pg_type entries that (by convention only) have the same names and namespaces. They cross-link to each other via pg_class.reltype and pg_type.typrelid. The associated pg_attribute entries have attrelid matching the pg_class OID. The catalog entries for the two cases are pretty nearly indistinguishable except for pg_class.relkind. Again, it's only by convention that we consider that the pg_type entry is primary for a composite type but pg_class is primary for a relation. Of course, a relation has some underlying storage (for most relkinds), and it will likely have associated entries in other catalogs that a composite type won't. But the core catalog entries are about the same. regards, tom lane