Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit77be5f9

Browse files
committed
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 testfailures here.
1 parenta390975 commit77be5f9

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

‎src/backend/utils/adt/timestamp.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.52 2001/10/0305:29:24 thomas Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.53 2001/10/0315:50:48 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -32,8 +32,7 @@
3232
staticdoubletime2t(constinthour,constintmin,constdoublesec);
3333
staticintEncodeSpecialTimestamp(Timestampdt,char*str);
3434
staticTimestampdt2local(Timestampdt,inttimezone);
35-
staticvoid
36-
AdjustTimestampForTypmod(Timestamp*time,int32typmod);
35+
staticvoidAdjustTimestampForTypmod(Timestamp*time,int32typmod);
3736

3837

3938
/*****************************************************************************
@@ -138,16 +137,16 @@ timestamp_scale(PG_FUNCTION_ARGS)
138137

139138
result=timestamp;
140139

141-
if (!TIMESTAMP_NOT_FINITE(result))
142-
AdjustTimestampForTypmod(&result,typmod);
140+
AdjustTimestampForTypmod(&result,typmod);
143141

144142
PG_RETURN_TIMESTAMP(result);
145143
}
146144

147145
staticvoid
148146
AdjustTimestampForTypmod(Timestamp*time,int32typmod)
149147
{
150-
if ((typmod >=0)&& (typmod <=13))
148+
if (!TIMESTAMP_NOT_FINITE(*time)&&
149+
(typmod >=0)&& (typmod <=13))
151150
{
152151
staticdoubleTimestampScale=1;
153152
staticint32TimestampTypmod=0;
@@ -157,8 +156,6 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod)
157156

158157
*time= (rint(((double)*time)*TimestampScale)/TimestampScale);
159158
}
160-
161-
return;
162159
}
163160

164161

@@ -261,8 +258,7 @@ timestamptz_scale(PG_FUNCTION_ARGS)
261258

262259
result=timestamp;
263260

264-
if (!TIMESTAMP_NOT_FINITE(result))
265-
AdjustTimestampForTypmod(&result,typmod);
261+
AdjustTimestampForTypmod(&result,typmod);
266262

267263
PG_RETURN_TIMESTAMPTZ(result);
268264
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp