Re: ERROR: int8 conversion to int4 is out of range

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Colin Campbell <sgcccdc(at)citec(dot)qld(dot)gov(dot)au>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ERROR: int8 conversion to int4 is out of range
Date: 2001-09-04 02:49:32
Message-ID: 24293.999571772@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Colin Campbell <sgcccdc(at)citec(dot)qld(dot)gov(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message cnliou 2001-09-04 03:07:05 How Does TEMP Table Work In Plpgsql?
Previous Message David Ford 2001-09-04 02:43:57 How to select using LIKE with bytea?