RE: Extracting metadata about attributes from catalog

From: "Bernardo Pons" <bernardo(at)atlas-iap(dot)es>
To: "Alex Pilosov" <alex(at)pilosoft(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Extracting metadata about attributes from catalog
Date: 2001-06-24 10:05:12
Message-ID: LOBBIBBGKNPMBFIKNEGGCEIACCAA.bernardo@atlas-iap.es
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> Do 'psql -E ...', it will display actual queries used by psql.

I already do it. At the end of my first message there was an example with
exactly the query you suggested.

> Your particular query is:
> SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull,
> a.atthasdef, a.attnum
> FROM pg_class c, pg_attribute a, pg_type t
> WHERE c.relname = '...tablename...'
> AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid
> ORDER BY a.attnum
>
> And pg_type has all information you need.

But, I'm afraid pg_type has not the information I need.

Just in case I missed something you have seen I wrote down a query showing
all attributes of the pg_type

SELECT a.attname, t.typname, t.typowner, t.typlen, t.typprtlen, t.typbyval,
t.typtype, t.typisdefined, t.typdelim, t.typrelid, t.typelem, t.typinput,
t.typoutput, t.typreceive, t.typsend, t.typalign, t.typdefault, a.atttypmod,
a.attnum FROM pg_class c, pg_attribute a, pg_type t WHERE c.relname =
..TABLENAME.. AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid
ORDER BY a.attnum;

but there's neither a field showing me, for example, a value 100 for a
varchar(100) field nor two fields showing value 6 and 2 for a numeric(6,2)
field.

Maybe I'm missing something from your answer?

Regards,

--
Bernardo Pons

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bernardo Pons 2001-06-24 10:05:13 RE: Extracting metadata about attributes from catalog
Previous Message Brian Hirt 2001-06-24 07:17:08 Fw: Problem with plpgsql functions and foreign key constraints.