Re: Getting lengths of variable fields

From: Boulat Khakimov <boulat(at)inet-interactif(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: Getting lengths of variable fields
Date: 2001-03-05 23:56:18
Message-ID: 3AA427A2.8C8B0B22@inet-interactif.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
>
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > Michelle Murrain writes:
> >> Is there something I am missing? Is there a way to get the size of variable
> >> length types using DBI/DBD::Pg, in particular, char() and varchar()?
>
> > Normally, you'd use LENGTH or OCTET_LENGTH. If you want to get the
> > storage size on disk, you could add 4 to what you get as length, but this
> > result seems to be of dubious value, especially with TOAST (compression,
> > out-of-line storage).
>
> What Michelle seems to want is the declared limit on field width, not
> the actual width of any particular value.
>
> This info is stored in the 'atttypmod' field of pg_attribute, but I
> don't know whether DBD::Pg provides any handy interface to that. You
> might have to get down-and-dirty enough to select it directly out of
> pg_attribute ...
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

Hi Tom,

When I query the pg_attribute table to get the limit on a specific field
I get more than one row, because I use the same field name in few
tables.
However each row has different "attrelid", I suppose that means that
every
table has its one unique "attrelid". My question is how do I find out
the
"attrelid" if I only know that table name??

That's the only thing that keeps me from getting max field limit for a
specific
field in a specific table...

Regards,
Boulat Khakimov

--
Nothing Like the Sun

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Patrick Welche 2001-03-06 00:00:53 epoch <-> timestamp
Previous Message Marek Pętlicki 2001-03-05 23:52:51 Re: Re: pgsql for Python