diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-10-03 15:50:48 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-10-03 15:50:48 +0000 |
commit | 77be5f9451280f356213c62823287337c4bb54ef (patch) | |
tree | 4dde2d1568d6206ee770522a77a50bbd1ca1b907 /src | |
parent | a390975cc14f76ff12c8b3fd97fc95510fed8a18 (diff) | |
download | postgresql-77be5f9451280f356213c62823287337c4bb54ef.tar.gz postgresql-77be5f9451280f356213c62823287337c4bb54ef.zip |
AdjustTimestampForTypmod does not work (at least not portably) on
-infinity and +infinity. Put TIMESTAMP_NOT_FINITE guard into the routine,
instead of forgetting it at some call sites. Fixes regression test
failures here.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/adt/timestamp.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 8bd0daf2bf6..112e8a26d6f 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.52 2001/10/03 05:29:24 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.53 2001/10/03 15:50:48 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -32,8 +32,7 @@ static double time2t(const int hour, const int min, const double sec); static int EncodeSpecialTimestamp(Timestamp dt, char *str); static Timestamp dt2local(Timestamp dt, int timezone); -static void -AdjustTimestampForTypmod(Timestamp *time, int32 typmod); +static void AdjustTimestampForTypmod(Timestamp *time, int32 typmod); /***************************************************************************** @@ -138,8 +137,7 @@ timestamp_scale(PG_FUNCTION_ARGS) result = timestamp; - if (! TIMESTAMP_NOT_FINITE(result)) - AdjustTimestampForTypmod(&result, typmod); + AdjustTimestampForTypmod(&result, typmod); PG_RETURN_TIMESTAMP(result); } @@ -147,7 +145,8 @@ timestamp_scale(PG_FUNCTION_ARGS) static void AdjustTimestampForTypmod(Timestamp *time, int32 typmod) { - if ((typmod >= 0) && (typmod <= 13)) + if (! TIMESTAMP_NOT_FINITE(*time) && + (typmod >= 0) && (typmod <= 13)) { static double TimestampScale = 1; static int32 TimestampTypmod = 0; @@ -157,8 +156,6 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod) *time = (rint(((double) *time)*TimestampScale)/TimestampScale); } - - return; } @@ -261,8 +258,7 @@ timestamptz_scale(PG_FUNCTION_ARGS) result = timestamp; - if (! TIMESTAMP_NOT_FINITE(result)) - AdjustTimestampForTypmod(&result, typmod); + AdjustTimestampForTypmod(&result, typmod); PG_RETURN_TIMESTAMPTZ(result); } |