RE: Extracting metadata about attributes from catalog - Mailing list pgsql-hackers

From Bernardo Pons
Subject RE: Extracting metadata about attributes from catalog
Date
Msg-id LOBBIBBGKNPMBFIKNEGGCEIACCAA.bernardo@atlas-iap.es
Whole thread Raw
In response to Re: Extracting metadata about attributes from catalog  (Alex Pilosov <alex@pilosoft.com>)
Responses RE: Extracting metadata about attributes from catalog  (Alex Pilosov <alex@pilosoft.com>)
List 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



pgsql-hackers by date:

Previous
From: "Bernardo Pons"
Date:
Subject: RE: Extracting metadata about attributes from catalog
Next
From: Marko Kreen
Date:
Subject: Re: [PATCH] by request: base64 for bytea