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

Commit826604f

Browse files
committed
Fix interval division and multiplication, before:
test=> select '4 months'::interval / 5; ?column?--------------- 1 mon -6 days(1 row)after:test=> select '4 months'::interval / 5; ?column?---------- 24 days(1 row)The problem was the use of rint() to round, and then find the remainder,causing the negative values.
1 parentca76df4 commit826604f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.132 2005/07/12 16:04:58 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.133 2005/07/20 03:50:24 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2201,7 +2201,7 @@ interval_mul(PG_FUNCTION_ARGS)
22012201
result->time+= (months-result->month)*INT64CONST(30)*
22022202
USECS_PER_DAY;
22032203
#else
2204-
result->month=rint(months);
2204+
result->month=(int)months;
22052205
result->time=JROUND(span1->time*factor);
22062206
/* evaluate fractional months as 30 days */
22072207
result->time+=JROUND((months-result->month)*30*SECS_PER_DAY);
@@ -2246,7 +2246,7 @@ interval_div(PG_FUNCTION_ARGS)
22462246
INT64CONST(30)*USECS_PER_DAY) /factor;
22472247
#else
22482248
months=span->month /factor;
2249-
result->month=rint(months);
2249+
result->month=(int)months;
22502250
result->time=JROUND(span->time /factor);
22512251
/* evaluate fractional months as 30 days */
22522252
result->time+=JROUND((months-result->month)*30*SECS_PER_DAY);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp