From: | Alex Pilosov <alex(at)pilosoft(dot)com> |
---|---|
To: | Bernardo Pons <bernardo(at)atlas-iap(dot)es> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | RE: Extracting metadata about attributes from catalog |
Date: | 2001-06-24 15:08:01 |
Message-ID: | Pine.BSO.4.10.10106241102590.9446-100000@spider.pilosoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sun, 24 Jun 2001, Bernardo Pons wrote:
>
> > 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
Sorry about that. For parameterized types (like numeric, varchar),
atttypmod contains specific information. For varchar-like parameters, its
length of the field+4 (54 means varchar(50), for example). For numeric
paremeter (numeric(a,b)), its 327680*b+a
I'm not sure if there's a better (and more documented) way to decode those
numbers, though.....
From | Date | Subject | |
---|---|---|---|
Next Message | Alex Pilosov | 2001-06-24 15:13:04 | Re: [PATCH] by request: base64 for bytea |
Previous Message | Tom Lane | 2001-06-24 15:01:49 | Re: stuck spin lock with many concurrent users |