Skip site navigation (1) Skip section navigation (2)

RE: Extracting metadata about attributes from catalog

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 (view raw or flat)
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.....


In response to

pgsql-hackers by date

Next:From: Alex PilosovDate: 2001-06-24 15:13:04
Subject: Re: [PATCH] by request: base64 for bytea
Previous:From: Tom LaneDate: 2001-06-24 15:01:49
Subject: Re: stuck spin lock with many concurrent users

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group