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

From Konstantin Izmailov
Subject programmatically retrieve details of a custom Postgres type
Date
Msg-id CAAw-Mse9DJf1wUa650jix04VKWx=r-u8OkqX=XHJBeLDo42eXQ@mail.gmail.com
Whole thread Raw
Responses Re: programmatically retrieve details of a custom Postgres type  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: programmatically retrieve details of a custom Postgres type  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-general
Hello,
I was unable to find how to get column names, sizes and types for a given composite type.

Example. For a type defines as:
  CREATE TYPE inventory_item AS (
  name text,
  supplier_id integer,
  price numeric
);

I have a plpgsql stored proc that returns SETOF inventory_item (i.e. there is no table with a column of this type).

I looked into the pg_type table but it only contains oid and typrelid for the inventory_item type. I need a query that returns information about structure of the composite type, i.e.:
  ColumnName  |  ColumnType  |  ColumnSize
  name             | text                | -1
  supplier_id      | integer           | 4
  price              | numeric          | 16

Is this possible? I'm executing queries via libpq...

Thank you!

pgsql-general by date:

Previous
From: Brad White
Date:
Subject: Re: Setting up replication on Windows, v9.4
Next
From: Pavel Stehule
Date:
Subject: Re: programmatically retrieve details of a custom Postgres type