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

Re: MetaData (size of datatype)

From: Hannu Krosing <hannu(at)tm(dot)ee>
To: Shra <shravan(at)yaskatech(dot)com>
Cc: Hannu Krosing <hannu(at)krosing(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: MetaData (size of datatype)
Date: 2002-04-29 13:54:01
Message-ID: 1020088441.27494.10.camel@taru.tm.ee (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-committerspgsql-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


In response to

pgsql-hackers by date

Next:From: Joel BurtonDate: 2002-04-29 14:08:20
Subject: pg_config Makefile includes hyphens in configure arguments
Previous:From: ShraDate: 2002-04-29 11:16:34
Subject: Re: MetaData (size of datatype)

pgsql-bugs by date

Next:From: Tom LaneDate: 2002-04-29 14:39:34
Subject: Re: MetaData (size of datatype)
Previous:From: ShraDate: 2002-04-29 11:16:34
Subject: Re: MetaData (size of datatype)

pgsql-committers by date

Next:From: Tom LaneDate: 2002-04-29 14:39:34
Subject: Re: MetaData (size of datatype)
Previous:From: ShraDate: 2002-04-29 11:16:34
Subject: Re: MetaData (size of datatype)

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