Index: backend/utils/adt/float.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/float.c,v retrieving revision 1.128 diff -c -r1.128 float.c *** backend/utils/adt/float.c 28 Jul 2006 18:33:04 -0000 1.128 --- backend/utils/adt/float.c 4 Oct 2006 21:16:20 -0000 *************** *** 327,332 **** --- 327,347 ---- } #endif /* HAVE_BUGGY_SOLARIS_STRTOD */ + #ifdef HAVE_BUGGY_IRIX_STRTOD + if(endptr != num && pg_strncasecmp(endptr,"inity",5)==0 && + endptr - num <=4 && + (pg_strncasecmp(num,"infinity",8)==0 || + pg_strncasecmp(num,"-infinity",9)==0 ) ) + { + /** + * + * Some versions of strtod (IRIX) stop + * parsing after "inf" and leave endptr as inity + */ + endptr+=5; + } + #endif + /* skip trailing whitespace */ while (*endptr != '\0' && isspace((unsigned char) *endptr)) endptr++; *************** *** 344,349 **** --- 359,377 ---- */ if (!isinf(val)) CheckFloat4Val(val); + #ifdef HAVE_BUGGY_IRIX_STRTOD + else { + /** + * If val is infinity, make sure that -infinity + * was not asked for. Some implementations of strtod + * return inf when passed -inf + */ + if(pg_strncasecmp(num,"-Infinity",9)==0 || + pg_strncasecmp(num,"-Inf",4)==0) { + val = -get_float4_infinity(); + } + } + #endif PG_RETURN_FLOAT4((float4) val); } *************** *** 494,499 **** --- 522,542 ---- } #endif /* HAVE_BUGGY_SOLARIS_STRTOD */ + #ifdef HAVE_BUGGY_IRIX_STRTOD + if(endptr != num && pg_strncasecmp(endptr,"inity",5)==0 && + endptr - num <=4 && + (pg_strncasecmp(num,"infinity",8)==0 || + pg_strncasecmp(num,"-infinity",9)==0 ) ) + { + /** + * + * Some versions of strtod (IRIX) stop + * parsing after "inf" and leave endptr as inity + */ + endptr+=5; + } + #endif + /* skip trailing whitespace */ while (*endptr != '\0' && isspace((unsigned char) *endptr)) endptr++; *************** *** 507,513 **** if (!isinf(val)) CheckFloat8Val(val); ! PG_RETURN_FLOAT8(val); } --- 550,568 ---- if (!isinf(val)) CheckFloat8Val(val); ! #ifdef HAVE_BUGGY_IRIX_STRTOD ! else { ! /** ! * If val is infinity, make sure that -infinity ! * was not asked for. Some implementations of strtod ! * return inf when passed -inf ! */ ! if(pg_strncasecmp(num,"-Infinity",9)==0 || ! pg_strncasecmp(num,"-Inf",4)==0) { ! val = -get_float8_infinity(); ! } ! } ! #endif PG_RETURN_FLOAT8(val); } Index: include/port/irix.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/port/irix.h,v retrieving revision 1.3 diff -c -r1.3 irix.h *** include/port/irix.h 11 Mar 2006 04:38:38 -0000 1.3 --- include/port/irix.h 4 Oct 2006 21:16:23 -0000 *************** *** 1 **** --- 1,2 ---- /* $PostgreSQL: pgsql/src/include/port/irix.h,v 1.3 2006/03/11 04:38:38 momjian Exp $ */ + #define HAVE_BUGGY_IRIX_STRTOD 1 Index: test/regress/expected/float4.out =================================================================== RCS file: /projects/cvsroot/pgsql/src/test/regress/expected/float4.out,v retrieving revision 1.13 diff -c -r1.13 float4.out *** test/regress/expected/float4.out 7 Apr 2005 01:51:40 -0000 1.13 --- test/regress/expected/float4.out 4 Oct 2006 21:16:25 -0000 *************** *** 85,90 **** --- 85,94 ---- NaN (1 row) + SELECT 'infinityinity'::float4; + ERROR: invalid input syntax for type real: "infinityinity" + SELECT '-infinityinity'::float4; + ERROR: invalid input syntax for type real: "-infinityinity" SELECT '' AS five, * FROM FLOAT4_TBL; five | f1 ------+------------- Index: test/regress/expected/float8.out =================================================================== RCS file: /projects/cvsroot/pgsql/src/test/regress/expected/float8.out,v retrieving revision 1.24 diff -c -r1.24 float8.out *** test/regress/expected/float8.out 8 Jun 2005 21:15:29 -0000 1.24 --- test/regress/expected/float8.out 4 Oct 2006 21:16:25 -0000 *************** *** 85,90 **** --- 85,94 ---- NaN (1 row) + SELECT 'infinityinity'::float8; + ERROR: invalid input syntax for type double precision: "infinityinity" + SELECT '-infinityinity'::float8; + ERROR: invalid input syntax for type double precision: "-infinityinity" SELECT '' AS five, * FROM FLOAT8_TBL; five | f1 ------+---------------------- Index: test/regress/sql/float4.sql =================================================================== RCS file: /projects/cvsroot/pgsql/src/test/regress/sql/float4.sql,v retrieving revision 1.8 diff -c -r1.8 float4.sql *** test/regress/sql/float4.sql 7 Apr 2005 01:51:41 -0000 1.8 --- test/regress/sql/float4.sql 4 Oct 2006 21:16:25 -0000 *************** *** 40,46 **** SELECT 'Infinity'::float4 + 100.0; SELECT 'Infinity'::float4 / 'Infinity'::float4; SELECT 'nan'::float4 / 'nan'::float4; ! SELECT '' AS five, * FROM FLOAT4_TBL; --- 40,47 ---- SELECT 'Infinity'::float4 + 100.0; SELECT 'Infinity'::float4 / 'Infinity'::float4; SELECT 'nan'::float4 / 'nan'::float4; ! SELECT 'infinityinity'::float4; ! SELECT '-infinityinity'::float4; SELECT '' AS five, * FROM FLOAT4_TBL; Index: test/regress/sql/float8.sql =================================================================== RCS file: /projects/cvsroot/pgsql/src/test/regress/sql/float8.sql,v retrieving revision 1.15 diff -c -r1.15 float8.sql *** test/regress/sql/float8.sql 8 Jun 2005 21:15:29 -0000 1.15 --- test/regress/sql/float8.sql 4 Oct 2006 21:16:25 -0000 *************** *** 40,45 **** --- 40,47 ---- SELECT 'Infinity'::float8 + 100.0; SELECT 'Infinity'::float8 / 'Infinity'::float8; SELECT 'nan'::float8 / 'nan'::float8; + SELECT 'infinityinity'::float8; + SELECT '-infinityinity'::float8; SELECT '' AS five, * FROM FLOAT8_TBL;