Re: ERROR: int8 conversion to int4 is out of range - Mailing list pgsql-general

From Tom Lane
Subject Re: ERROR: int8 conversion to int4 is out of range
Date
Msg-id 24293.999571772@sss.pgh.pa.us
Whole thread Raw
In response to Re: ERROR: int8 conversion to int4 is out of range  (Colin Campbell <sgcccdc@citec.qld.gov.au>)
List pgsql-general
Colin Campbell <sgcccdc@citec.qld.gov.au> writes:
> Fixed it. (If anyone cares :-) Seems it might be a gcc optimizer
> "feature".

Which gcc version, on just what platform, was that again?

> The code in backend/utils/adt/int8.c was:

>         if ((val < (int64)INT_MIN) || (val > (int64)INT_MAX))
>                 elog(ERROR, "int8 conversion to int4 is out of range");

> If I changed it to

>         if ((val < INT_MIN))
>                 elog(ERROR, "int8 conversion to int4 is out of range - too small");
>         if ((val > INT_MAX))
>                 elog(ERROR, "int8 conversion to int4 is out of range - too big");

> the error went away.

Hmm, there seem to be two changes here.  Is it the splitup of the OR
test, or the removal of the (int64) casts that does the trick?  Or
do you really need both changes?

I wouldn't mind applying the OR splitup to the master sources, but I'm
a little more paranoid about applying the cast removal.  Seems like that
might induce problems on other compilers.  So I'm hoping you only need
the OR splitup to make it work.

            regards, tom lane

pgsql-general by date:

Previous
From: David Ford
Date:
Subject: How to select using LIKE with bytea?
Next
From:
Date:
Subject: How Does TEMP Table Work In Plpgsql?