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

Commite3a5ac2

Browse files
Jan WieckJan Wieck
Jan Wieck
authored and
Jan Wieck
committed
Little fix for round() function
Jan
1 parent9f65dfe commite3a5ac2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
*1998 Jan Wieck
77
*
8-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.5 1999/01/03 05:30:47 momjian Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.6 1999/01/04 11:20:33 wieck Exp $
99
*
1010
* ----------
1111
*/
@@ -523,6 +523,7 @@ Numeric
523523
numeric_round(Numericnum,int32scale)
524524
{
525525
int32typmod;
526+
intprecision;
526527

527528
/* ----------
528529
* Handle NULL
@@ -553,7 +554,9 @@ numeric_round(Numeric num, int32 scale)
553554
* Let numeric() and in turn apply_typmod() do the job
554555
* ----------
555556
*/
556-
typmod= (((num->n_weight+scale+1) <<16) |scale)+VARHDRSZ;
557+
precision=MAX(0,num->n_weight)+scale;
558+
precision=MIN(precision,NUMERIC_MAX_PRECISION);
559+
typmod= (((precision+2) <<16) |scale)+VARHDRSZ;
557560
returnnumeric(num,typmod);
558561
}
559562

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp