Re: programmatically retrieve details of a custom Postgres type - Mailing list pgsql-general

From Tom Lane
Subject Re: programmatically retrieve details of a custom Postgres type
Date
Msg-id 454980.1668139813@sss.pgh.pa.us
Whole thread Raw
In response to programmatically retrieve details of a custom Postgres type  (Konstantin Izmailov <pgfizm@gmail.com>)
Responses Re: programmatically retrieve details of a custom Postgres type  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Konstantin Izmailov <pgfizm@gmail.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



pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: programmatically retrieve details of a custom Postgres type
Next
From: Tom Lane
Date:
Subject: Re: programmatically retrieve details of a custom Postgres type