Re: programmatically retrieve details of a custom Postgres type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Konstantin Izmailov <pgfizm(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: programmatically retrieve details of a custom Postgres type
Date: 2022-11-11 04:10:13
Message-ID: 454980.1668139813@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Konstantin Izmailov <pgfizm(at)gmail(dot)com> writes:
> I was unable to find how to get column names, sizes and types for a given
> 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_attribute a on t.typrelid = a.attrelid where typname = 'complex' order by attnum;
attname | atttypid
---------+------------------
r | double precision
i | double precision
(2 rows)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2022-11-11 04:30:32 Re: programmatically retrieve details of a custom Postgres type
Previous Message Pavel Stehule 2022-11-11 04:09:51 Re: programmatically retrieve details of a custom Postgres type