On Tue, 7 Aug 2001, Dave Cramer wrote: > This came into the jdbc list > > Apparently bigint is not really 8 bytes??? > > I test this out with psql > > test=# create table testbigint (id serial, fp0 int8); > NOTICE: CREATE TABLE will create implicit sequence 'testbigint_id_seq' > for SERIAL column 'testbigint.id' > NOTICE: CREATE TABLE/UNIQUE will create implicit index > 'testbigint_id_key' for table 'testbigint' > CREATE > test=# insert into testbigint (fp0) values (1); > INSERT 333698 1 > test=# update testbigint set fp0 = -9223372036854775808 where id = 1; > ERROR: int8 value out of range: "-9223372036854775808" Yes, it's failing on precisely the minimum value. It appears that the code that does this sets the sign and then makes the number and applies the sign at the end which would be wrong in this case (as it overflows on 9223372036854775808) I don't think my patch against recent sources would apply cleanly to older ones, and I didn't run the regression against it, but it seemed to work, and is only a two line change in current source.
*** pgsql.virg/src/backend/utils/adt/int8.c Sat Apr 14 16:07:18 2001 --- pgsql/src/backend/utils/adt/int8.c Tue Aug 7 03:05:27 2001 *************** *** 77,83 **** elog(ERROR, "Bad int8 external representation \"%s\"", str); while (*ptr && isdigit((unsigned char) *ptr)) /* process digits */ { ! int64 newtmp = tmp * 10 + (*ptr++ - '0'); if ((newtmp / 10) != tmp) /* overflow? */ elog(ERROR, "int8 value out of range: \"%s\"", str); --- 77,83 ---- elog(ERROR, "Bad int8 external representation \"%s\"", str); while (*ptr && isdigit((unsigned char) *ptr)) /* process digits */ { ! int64 newtmp = tmp * 10 + (*ptr++ - '0') * sign; if ((newtmp / 10) != tmp) /* overflow? */ elog(ERROR, "int8 value out of range: \"%s\"", str); *************** *** 86,92 **** if (*ptr) /* trailing junk? */ elog(ERROR, "Bad int8 external representation \"%s\"", str); ! result = (sign < 0) ? -tmp : tmp; PG_RETURN_INT64(result); } --- 86,92 ---- if (*ptr) /* trailing junk? */ elog(ERROR, "Bad int8 external representation \"%s\"", str); ! result = tmp; PG_RETURN_INT64(result); }
---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]