Re: MetaData (size of datatype) - Mailing list pgsql-hackers

From Shra
Subject Re: MetaData (size of datatype)
Date
Msg-id f0204291714560232@yaskatech.com
Whole thread Raw
In response to ...  (Shra <shravan@yaskatech.com>)
Responses Re: MetaData (size of datatype)  (Hannu Krosing <hannu@tm.ee>)
Re: MetaData (size of datatype)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
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
valueof 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..........

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 .........

any better way , please.........

Shra



pgsql-hackers by date:

Previous
From: Shra
Date:
Subject: MetaData (size of datatype)
Next
From: Hannu Krosing
Date:
Subject: Re: MetaData (size of datatype)