Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fc96a5f

Browse files
committed
Blind try to fix portability issue in commit 8f93bd8 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 d9476b8. 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.
1 parent 404756f commit fc96a5f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/backend/utils/adt/timestamp.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -764,12 +764,8 @@ float8_timestamptz(PG_FUNCTION_ARGS)
764764
{
765765
/* Out of range? */
766766
if (seconds <
767-
(float8) SECS_PER_DAY * (DATETIME_MIN_JULIAN - UNIX_EPOCH_JDATE))
768-
ereport(ERROR,
769-
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
770-
errmsg("timestamp out of range: \"%g\"", seconds)));
771-
772-
if (seconds >=
767+
(float8) SECS_PER_DAY * (DATETIME_MIN_JULIAN - UNIX_EPOCH_JDATE)
768+
|| seconds >=
773769
(float8) SECS_PER_DAY * (TIMESTAMP_END_JULIAN - UNIX_EPOCH_JDATE))
774770
ereport(ERROR,
775771
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
@@ -779,7 +775,8 @@ float8_timestamptz(PG_FUNCTION_ARGS)
779775
seconds -= ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY);
780776

781777
#ifdef HAVE_INT64_TIMESTAMP
782-
result = rint(seconds * USECS_PER_SEC);
778+
seconds = rint(seconds * USECS_PER_SEC);
779+
result = (int64) seconds;
783780
#else
784781
result = seconds;
785782
#endif
@@ -1615,9 +1612,10 @@ make_interval(PG_FUNCTION_ARGS)
16151612
result->day = weeks * 7 + days;
16161613

16171614
#ifdef HAVE_INT64_TIMESTAMP
1615+
secs = rint(secs * USECS_PER_SEC);
16181616
result->time = hours * ((int64) SECS_PER_HOUR * USECS_PER_SEC) +
16191617
mins * ((int64) SECS_PER_MINUTE * USECS_PER_SEC) +
1620-
(int64) rint(secs * USECS_PER_SEC);
1618+
(int64) secs;
16211619
#else
16221620
result->time = hours * (double) SECS_PER_HOUR +
16231621
mins * (double) SECS_PER_MINUTE +

0 commit comments

Comments
 (0)