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 1otLMw-0000YZ-Pj for pgsql-general@arkaria.postgresql.org; Fri, 11 Nov 2022 04:10:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1otLMv-0006th-Ne for pgsql-general@arkaria.postgresql.org; Fri, 11 Nov 2022 04:10:17 +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 1otLMv-0006tY-CH for pgsql-general@lists.postgresql.org; Fri, 11 Nov 2022 04:10:17 +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 1otLMt-00011J-0l for pgsql-general@postgresql.org; Fri, 11 Nov 2022 04:10:16 +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 2AB4AD6L454981; Thu, 10 Nov 2022 23:10:13 -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: References: Comments: In-reply-to Konstantin Izmailov message dated "Thu, 10 Nov 2022 21:02:12 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <454979.1668139813.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 10 Nov 2022 23:10:13 -0500 Message-ID: <454980.1668139813@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Konstantin Izmailov writes: > I was unable to find how to get column names, sizes and types for a give= n > composite type. For a composite type, pg_type.typrelid links to pg_class and pg_attribute entries that work much like a table. For instance, # select a.attname, a.atttypid::regtype from pg_type t left join pg_attrib= ute a on t.typrelid =3D a.attrelid where typname =3D 'complex' order by at= tnum; = attname | atttypid = ---------+------------------ r | double precision i | double precision (2 rows) regards, tom lane