Re: Maximum limit on int in plpgsql

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: deepthi(at)granwill(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Maximum limit on int in plpgsql
Date: 2004-11-30 11:03:33
Message-ID: 1101812613.8902.81.camel@sabrina.peacock.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Am Dienstag, den 30.11.2004, 02:29 -0800 schrieb deepthi(at)granwill(dot)com:
> Hello,
>
> I am passing the ip address as a varchar. Eg: 133.9.4.11
>
> Later on i am splitting the ip address with the delimiter as '.'
>
>
> ip1t:= split_part($1,'.',1); // returns a text value
> ip2t:= split_part($1,'.',2); // returns a text value
> ip3t:= split_part($1,'.',3);
> ip4t:= split_part($1,'.',4);
>
> Then i am type casting it into an integer
>
> select into ip1 cast(ip1t as integer);
> select into ip2 cast(ip2t as integer);
> select into ip3 cast(ip3t as integer);
> select into ip4 cast(ip4t as integer);
>
> The i am taking the sum using this formula
>
> out_sum=ip1*256*256*256+ip2*256*256+ip3*256+ip4;
>
> When i run the procedure i am getting following error
> pg_atoi : Numerical result out of range
>
> I tried all possible datatypes but still i am getting the same error.
>
> Is it the problem of typecasting or the limits on datatype?

integer means int4 iirc.
Which is 32 bit, but signed so you only have 2^31-1 as maxint
Did you try int8 here too?
btw. there are IP datatypes in PG as well. Otoh, they dont support
ip->int8 conversion. It depends on what are your plans once you
have that number.

Regards
Tino

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2004-11-30 11:12:35 Re: Temporal query question
Previous Message Tino Wildenhain 2004-11-30 10:44:05 Re: change natural column order