Thread: 8.2beta1 failure on IRIX
I'm getting some failures in the regression tests on 8.2beta1 on IRIX. It looks like IRIX (or at least some versions) has a broken strtod. The float4 and float8 tests fail, I've attached a patch to tools/adt/float.c that fixes the problem along with the regression output. As a side note,could float4in not be refactored to just call float8in followed by CheckFloat4Val and maybe some error message changes? The two functions have a lot of duplicated code. IRIX 6.5.22m uname -R = 6.5 6.5.22m
ssinger_pg@sympatico.ca writes: > I'm getting some failures in the regression tests on 8.2beta1 on IRIX. > It looks like IRIX (or at least some versions) has a broken strtod. > The float4 and float8 tests fail, I've attached a patch to > tools/adt/float.c that fixes the problem along with the regression output. That patch is pretty seriously broken (not only because it's not ifdef'd to apply only on the platform that needs it, but because it'll do the wrong thing with "infinityinity"). But what I'm really wondering is why we've not heard of this before? That code hasn't been changed in quite some time. regards, tom lane
On Sun, 1 Oct 2006, Tom Lane wrote: Does this version of the patch address your concerns. Some searching of the net shows that this has been reported before. Once in the beta for 8.1 and again in January as bug #2192 (It looks like a patch was included then but wasn't applied). It seems like only certain versions of IRIX have this problem but I don't know how common it is or what versions don't have the bug. Unless we want to drop IRIX from the list of supported platforms we should apply one of the fixes. > ssinger_pg@sympatico.ca writes: >> I'm getting some failures in the regression tests on 8.2beta1 on IRIX. >> It looks like IRIX (or at least some versions) has a broken strtod. >> The float4 and float8 tests fail, I've attached a patch to >> tools/adt/float.c that fixes the problem along with the regression output. > > That patch is pretty seriously broken (not only because it's not ifdef'd > to apply only on the platform that needs it, but because it'll do the > wrong thing with "infinityinity"). But what I'm really wondering is why > we've not heard of this before? That code hasn't been changed in quite > some time. > > regards, tom lane >
Steve Singer <ssinger_pg@sympatico.ca> writes: > Some searching of the net shows that this has been reported before. Once in > the beta for 8.1 and again in January as bug #2192 (It looks like a patch > was included then but wasn't applied). Yeah, I see that, not sure why we didn't apply that patch. Will work on this. regards, tom lane
I've applied the attached patch which merges ideas from your version and John Jorgensen's. Please check it. regards, tom lane *** src/backend/utils/adt/float.c.orig Tue Oct 3 23:16:36 2006 --- src/backend/utils/adt/float.c Wed Oct 4 21:21:17 2006 *************** *** 328,333 **** --- 328,359 ---- } #endif /* HAVE_BUGGY_SOLARIS_STRTOD */ + #ifdef HAVE_BUGGY_IRIX_STRTOD + /* + * In some IRIX versions, strtod() recognizes only "inf", so if the + * input is "infinity" we have to skip over "inity". Also, it may + * return positive infinity for "-inf". + */ + if (isinf(val)) + { + if (pg_strncasecmp(num, "Infinity", 8) == 0) + { + val = get_float4_infinity(); + endptr = num + 8; + } + else if (pg_strncasecmp(num, "-Infinity", 9) == 0) + { + val = -get_float4_infinity(); + endptr = num + 9; + } + else if (pg_strncasecmp(num, "-inf", 4) == 0) + { + val = -get_float4_infinity(); + endptr = num + 4; + } + } + #endif /* HAVE_BUGGY_IRIX_STRTOD */ + /* skip trailing whitespace */ while (*endptr != '\0' && isspace((unsigned char) *endptr)) endptr++; *************** *** 494,499 **** --- 520,551 ---- endptr--; } #endif /* HAVE_BUGGY_SOLARIS_STRTOD */ + + #ifdef HAVE_BUGGY_IRIX_STRTOD + /* + * In some IRIX versions, strtod() recognizes only "inf", so if the + * input is "infinity" we have to skip over "inity". Also, it may + * return positive infinity for "-inf". + */ + if (isinf(val)) + { + if (pg_strncasecmp(num, "Infinity", 8) == 0) + { + val = get_float8_infinity(); + endptr = num + 8; + } + else if (pg_strncasecmp(num, "-Infinity", 9) == 0) + { + val = -get_float8_infinity(); + endptr = num + 9; + } + else if (pg_strncasecmp(num, "-inf", 4) == 0) + { + val = -get_float8_infinity(); + endptr = num + 4; + } + } + #endif /* HAVE_BUGGY_IRIX_STRTOD */ /* skip trailing whitespace */ while (*endptr != '\0' && isspace((unsignedchar) *endptr)) *** src/include/port/irix.h.orig Fri Mar 10 23:38:38 2006 --- src/include/port/irix.h Wed Oct 4 21:20:50 2006 *************** *** 1 **** --- 1,7 ---- /* $PostgreSQL: pgsql/src/include/port/irix.h,v 1.3 2006/03/11 04:38:38 momjian Exp $ */ + + /* + * IRIX 6.5.26f and 6.5.22f (at least) have a strtod() that accepts + * "infinity", but leaves endptr pointing to "inity". + */ + #define HAVE_BUGGY_IRIX_STRTOD
On Wed, 4 Oct 2006, Tom Lane wrote: I've applied the patch and it seems to fix the problems. 8.2beta1 + the patch passes all of the regression tests on the IRIX box (accept the expected difference with the geometry test). > I've applied the attached patch which merges ideas from your version and > John Jorgensen's. Please check it. > > regards, tom lane > > *** src/backend/utils/adt/float.c.orig Tue Oct 3 23:16:36 2006 > --- src/backend/utils/adt/float.c Wed Oct 4 21:21:17 2006 > *************** > *** 328,333 **** > --- 328,359 ---- > } > #endif /* HAVE_BUGGY_SOLARIS_STRTOD */ > > + #ifdef HAVE_BUGGY_IRIX_STRTOD > + /* > + * In some IRIX versions, strtod() recognizes only "inf", so if the > + * input is "infinity" we have to skip over "inity". Also, it may > + * return positive infinity for "-inf". > + */ > + if (isinf(val)) > + { > + if (pg_strncasecmp(num, "Infinity", 8) == 0) > + { > + val = get_float4_infinity(); > + endptr = num + 8; > + } > + else if (pg_strncasecmp(num, "-Infinity", 9) == 0) > + { > + val = -get_float4_infinity(); > + endptr = num + 9; > + } > + else if (pg_strncasecmp(num, "-inf", 4) == 0) > + { > + val = -get_float4_infinity(); > + endptr = num + 4; > + } > + } > + #endif /* HAVE_BUGGY_IRIX_STRTOD */ > + > /* skip trailing whitespace */ > while (*endptr != '\0' && isspace((unsigned char) *endptr)) > endptr++; > *************** > *** 494,499 **** > --- 520,551 ---- > endptr--; > } > #endif /* HAVE_BUGGY_SOLARIS_STRTOD */ > + > + #ifdef HAVE_BUGGY_IRIX_STRTOD > + /* > + * In some IRIX versions, strtod() recognizes only "inf", so if the > + * input is "infinity" we have to skip over "inity". Also, it may > + * return positive infinity for "-inf". > + */ > + if (isinf(val)) > + { > + if (pg_strncasecmp(num, "Infinity", 8) == 0) > + { > + val = get_float8_infinity(); > + endptr = num + 8; > + } > + else if (pg_strncasecmp(num, "-Infinity", 9) == 0) > + { > + val = -get_float8_infinity(); > + endptr = num + 9; > + } > + else if (pg_strncasecmp(num, "-inf", 4) == 0) > + { > + val = -get_float8_infinity(); > + endptr = num + 4; > + } > + } > + #endif /* HAVE_BUGGY_IRIX_STRTOD */ > > /* skip trailing whitespace */ > while (*endptr != '\0' && isspace((unsigned char) *endptr)) > *** src/include/port/irix.h.orig Fri Mar 10 23:38:38 2006 > --- src/include/port/irix.h Wed Oct 4 21:20:50 2006 > *************** > *** 1 **** > --- 1,7 ---- > /* $PostgreSQL: pgsql/src/include/port/irix.h,v 1.3 2006/03/11 04:38:38 momjian Exp $ */ > + > + /* > + * IRIX 6.5.26f and 6.5.22f (at least) have a strtod() that accepts > + * "infinity", but leaves endptr pointing to "inity". > + */ > + #define HAVE_BUGGY_IRIX_STRTOD >