Commit 5d2adf0f authored by Tom Lane's avatar Tom Lane

Blind try to fix portability issue in commit 8f93bd85 et al.

The S/390 members of the buildfarm are showing failures indicating
that they're having trouble with the rint() calls I added yesterday.
There's no good reason for that, and I wonder if it is a compiler bug
similar to the one we worked around in d9476b83.  Try to fix it using
the same method as before, namely to store the result of rint() back
into a "double" variable rather than immediately converting to int64.
(This isn't entirely waving a dead chicken, since on machines with
wider-than-double float registers, the extra store forces a width
conversion.  I don't know if S/390 is like that, but it seems worth
trying.)

In passing, merge duplicate ereport() calls in float8_timestamptz().

Per buildfarm.
parent 806091c9
...@@ -773,12 +773,8 @@ float8_timestamptz(PG_FUNCTION_ARGS) ...@@ -773,12 +773,8 @@ float8_timestamptz(PG_FUNCTION_ARGS)
{ {
/* Out of range? */ /* Out of range? */
if (seconds < if (seconds <
(float8) SECS_PER_DAY * (DATETIME_MIN_JULIAN - UNIX_EPOCH_JDATE)) (float8) SECS_PER_DAY * (DATETIME_MIN_JULIAN - UNIX_EPOCH_JDATE)
ereport(ERROR, || seconds >=
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
errmsg("timestamp out of range: \"%g\"", seconds)));
if (seconds >=
(float8) SECS_PER_DAY * (TIMESTAMP_END_JULIAN - UNIX_EPOCH_JDATE)) (float8) SECS_PER_DAY * (TIMESTAMP_END_JULIAN - UNIX_EPOCH_JDATE))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
...@@ -788,7 +784,8 @@ float8_timestamptz(PG_FUNCTION_ARGS) ...@@ -788,7 +784,8 @@ float8_timestamptz(PG_FUNCTION_ARGS)
seconds -= ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY); seconds -= ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY);
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
result = rint(seconds * USECS_PER_SEC); seconds = rint(seconds * USECS_PER_SEC);
result = (int64) seconds;
#else #else
result = seconds; result = seconds;
#endif #endif
...@@ -1624,9 +1621,10 @@ make_interval(PG_FUNCTION_ARGS) ...@@ -1624,9 +1621,10 @@ make_interval(PG_FUNCTION_ARGS)
result->day = weeks * 7 + days; result->day = weeks * 7 + days;
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
secs = rint(secs * USECS_PER_SEC);
result->time = hours * ((int64) SECS_PER_HOUR * USECS_PER_SEC) + result->time = hours * ((int64) SECS_PER_HOUR * USECS_PER_SEC) +
mins * ((int64) SECS_PER_MINUTE * USECS_PER_SEC) + mins * ((int64) SECS_PER_MINUTE * USECS_PER_SEC) +
(int64) rint(secs * USECS_PER_SEC); (int64) secs;
#else #else
result->time = hours * (double) SECS_PER_HOUR + result->time = hours * (double) SECS_PER_HOUR +
mins * (double) SECS_PER_MINUTE + mins * (double) SECS_PER_MINUTE +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment