From: Tom Lane <tgl@sss.pgh.pa.us>
To: Konstantin Izmailov <pgfizm@gmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: programmatically retrieve details of a custom Postgres type
Date: Thu, 10 Nov 2022 23:10:13 -0500
Message-ID: <454980.1668139813@sss.pgh.pa.us> (raw)
In-Reply-To: <CAAw-Mse9DJf1wUa650jix04VKWx=r-u8OkqX=XHJBeLDo42eXQ@mail.gmail.com>
References: <CAAw-Mse9DJf1wUa650jix04VKWx=r-u8OkqX=XHJBeLDo42eXQ@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, pgfizm@gmail.com
Subject: Re: programmatically retrieve details of a custom Postgres type
In-Reply-To: <454980.1668139813@sss.pgh.pa.us>
References: <CAAw-Mse9DJf1wUa650jix04VKWx=r-u8OkqX=XHJBeLDo42eXQ@mail.gmail.com> <454980.1668139813@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox