Index: backend/utils/adt/float.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/float.c,v retrieving revision 1.128 diff -c -w -r1.128 float.c *** backend/utils/adt/float.c 28 Jul 2006 18:33:04 -0000 1.128 --- backend/utils/adt/float.c 30 Sep 2006 23:38:17 -0000 *************** *** 326,331 **** --- 326,343 ---- endptr--; } #endif /* HAVE_BUGGY_SOLARIS_STRTOD */ + if(endptr != num && pg_strncasecmp(endptr,"inity",5)==0 && + (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; + } + /* skip trailing whitespace */ while (*endptr != '\0' && isspace((unsigned char) *endptr)) *************** *** 342,349 **** * if we get here, we have a legal double, still need to check to see if * it's a legal float4 */ ! if (!isinf(val)) CheckFloat4Val(val); PG_RETURN_FLOAT4((float4) val); } --- 354,373 ---- * if we get here, we have a legal double, still need to check to see if * it's a legal float4 */ ! if (!isinf(val)) { CheckFloat4Val(val); + } + 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",5)==0) { + val = -get_float4_infinity(); + } + } PG_RETURN_FLOAT4((float4) val); } *************** *** 493,498 **** --- 517,533 ---- endptr--; } #endif /* HAVE_BUGGY_SOLARIS_STRTOD */ + if(endptr != num && pg_strncasecmp(endptr,"inity",5)==0 && + (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; + } /* skip trailing whitespace */ while (*endptr != '\0' && isspace((unsigned char) *endptr)) *************** *** 507,513 **** if (!isinf(val)) CheckFloat8Val(val); ! PG_RETURN_FLOAT8(val); } --- 542,558 ---- if (!isinf(val)) CheckFloat8Val(val); ! 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",5)==0) { ! val = -get_float4_infinity(); ! } ! } PG_RETURN_FLOAT8(val); }