pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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:30:32 -0500
Message-ID: <457233.1668141032@sss.pgh.pa.us> (raw)
In-Reply-To: <454980.1668139813@sss.pgh.pa.us>
References: <CAAw-Mse9DJf1wUa650jix04VKWx=r-u8OkqX=XHJBeLDo42eXQ@mail.gmail.com>
	<454980.1668139813@sss.pgh.pa.us>

I wrote:
> For a composite type, pg_type.typrelid links to pg_class and pg_attribute
> entries that work much like a table.

Actually, you could reverse that: for a table, pg_type.typrelid links to
pg_class and pg_attribute entries that work much like a composite type.

For both relations and composite types, there are pg_class and pg_type
entries that (by convention only) have the same names and namespaces.
They cross-link to each other via pg_class.reltype and pg_type.typrelid.
The associated pg_attribute entries have attrelid matching the pg_class
OID.  The catalog entries for the two cases are pretty nearly
indistinguishable except for pg_class.relkind.  Again, it's only by
convention that we consider that the pg_type entry is primary for a
composite type but pg_class is primary for a relation.

Of course, a relation has some underlying storage (for most relkinds),
and it will likely have associated entries in other catalogs that a
composite type won't.  But the core catalog entries are about the same.

			regards, tom lane





view thread (5+ messages)  latest in thread

Message-ID: <457233.1668141032@sss.pgh.pa.us>
Permalink:  ../457233.1668141032@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/457233.1668141032@sss.pgh.pa.us

 · 

reply

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: <457233.1668141032@sss.pgh.pa.us>
  References: <CAAw-Mse9DJf1wUa650jix04VKWx=r-u8OkqX=XHJBeLDo42eXQ@mail.gmail.com> <454980.1668139813@sss.pgh.pa.us> <457233.1668141032@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