提交 08195a43 编写于 作者: T Tom Lane

Fix bugs in NUMERIC ceil() and floor() functions. ceil(0) returned 1,

and both would insert random junk digits if given an input that was an
exact multiple of 10.
上级 6d1efd76
......@@ -5,7 +5,7 @@
*
* 1998 Jan Wieck
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.23 2000/01/18 03:44:41 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.24 2000/01/20 02:21:44 tgl Exp $
*
* ----------
*/
......@@ -2932,7 +2932,7 @@ ceil_var(NumericVar *var, NumericVar *result)
set_var_from_var(var, &tmp);
tmp.rscale = 0;
tmp.ndigits = MAX(0, tmp.weight + 1);
tmp.ndigits = MIN(tmp.ndigits, MAX(0, tmp.weight + 1));
if (tmp.sign == NUMERIC_POS && cmp_var(var, &tmp) != 0)
add_var(&tmp, &const_one, &tmp);
......@@ -2957,7 +2957,7 @@ floor_var(NumericVar *var, NumericVar *result)
set_var_from_var(var, &tmp);
tmp.rscale = 0;
tmp.ndigits = MAX(0, tmp.weight + 1);
tmp.ndigits = MIN(tmp.ndigits, MAX(0, tmp.weight + 1));
if (tmp.sign == NUMERIC_NEG && cmp_var(var, &tmp) != 0)
sub_var(&tmp, &const_one, &tmp);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册