summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane2019-03-11 15:25:23 +0000
committerTom Lane2019-03-11 15:25:26 +0000
commitb212245f96437b574b59993c772e4d9276965e49 (patch)
treeaeb183835c0f921d6f45b38d631d774fa8eeaf45 /src
parent08cecfaf60c484f219ba7e6ee23e9699aea4e9af (diff)
In guc.c, ignore ERANGE errors from strtod().
Instead, just proceed with the infinity or zero result that it should return for overflow/underflow. This avoids a platform dependency, in that various versions of strtod are inconsistent about whether they signal ERANGE for a value that's specified as infinity. It's possible this won't be enough to remove the buildfarm failures we're seeing from ac75959cd, in which case I'll take out the infinity test case that commit added. But first let's see if we can fix it. Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/misc/guc.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index fe6c6f8a05a..1c4f9ac04e6 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -6240,13 +6240,15 @@ parse_real(const char *value, double *result, int flags, const char **hintmsg)
if (hintmsg)
*hintmsg = NULL;
- errno = 0;
val = strtod(value, &endptr);
+ if (endptr == value)
+ return false; /* no HINT for syntax error */
- if (endptr == value || errno == ERANGE)
- return false; /* no HINT for these cases */
-
- /* reject NaN (infinities will fail range checks later) */
+ /*
+ * We ignore strtod's errno, so that out-of-range inputs will just result
+ * in zero or infinity values. Subsequent range checks will reject those
+ * if necessary. We do need to reject NaN explicitly, however.
+ */
if (isnan(val))
return false; /* treat same as syntax error; no HINT */