Re: MetaData (size of datatype)

Поиск
Список
Период
Сортировка
От Hannu Krosing
Тема Re: MetaData (size of datatype)
Дата
Msg-id 1020088441.27494.10.camel@taru.tm.ee
обсуждение исходный текст
Ответ на Re: MetaData (size of datatype)  (Shra <shravan@yaskatech.com>)
Список pgsql-hackers
On Mon, 2002-04-29 at 13:16, Shra wrote:
> Hi Hannu,
> 
> > -1 is given for types that are of fixed size and whose length can be
> > read from pg_type.typlen for that type.
> 
> I don't think so...jsut look into this file pq_type.h.... it says.........
> *****************************************************************
>  typlen is the number of bytes we use to represent a value of this type, e.g. 
> 4 for an int4.  But for a variable length type, typlen is -1
> *****************************************************************
> 
> -1 is for variable length n not for fixed length.........this point is very 
> clear even in documentation..........

Yes, it in pg_type.typlen it is -1 is for variable length and actual
length for fixed-length types

in pg_attribute.attypmod it is -1 for _fixed_ length types and actual
length for variable length types (actual length = defined length + 4
bytes of length bytes)

> now how to find length for a numeric, varchar or anyother one that has 
> variable length where the system PQfsize returns -1.........?
> 
> As tom said.....The type is encoded in the atttypmod field (see PQfmod) and 
> recommended using format_type().....
> but when this is used, it returns -1 for integer , real n other fixed 
> datatypes .........

so do as Tom said - 

if   PQfsize returns -1
then   use  PQfmod
else   use PQfsize

-----------
Hannu



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Shra
Дата:
Сообщение: Re: MetaData (size of datatype)
Следующее
От: Shad
Дата:
Сообщение: Re: PSQL \x \l command issues