Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
6b4e9d16
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6b4e9d16
编写于
5月 08, 2008
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Have numeric 0 ^ 4.3 return 1, rather than an error, and have 0 ^ 0.0
return 1, rather than error. This was already the float8 behavior.
上级
eabd1b2e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
7 deletion
+16
-7
src/backend/utils/adt/numeric.c
src/backend/utils/adt/numeric.c
+16
-7
未找到文件。
src/backend/utils/adt/numeric.c
浏览文件 @
6b4e9d16
...
...
@@ -14,7 +14,7 @@
* Copyright (c) 1998-2008, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.11
0 2008/04/21 00:26:45 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.11
1 2008/05/08 19:25:38 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -5170,6 +5170,21 @@ power_var(NumericVar *base, NumericVar *exp, NumericVar *result)
int
local_rscale
;
double
val
;
/*
* This avoids log(0) for cases of 0 raised to a non-integer.
* Also, while 0 ^ 0 can be either 1 or indeterminate (error), we
* treat it as one because most programming languages do this.
* http://en.wikipedia.org/wiki/Exponentiation#Zero_to_the_zero_power
*/
if
(
cmp_var
(
base
,
&
const_zero
)
==
0
)
{
if
(
cmp_var
(
exp
,
&
const_zero
)
==
0
)
set_var_from_var
(
&
const_one
,
result
);
else
set_var_from_var
(
&
const_zero
,
result
);
return
;
}
/* If exp can be represented as an integer, use power_var_int */
if
(
exp
->
ndigits
==
0
||
exp
->
ndigits
<=
exp
->
weight
+
1
)
{
...
...
@@ -5266,15 +5281,9 @@ power_var_int(NumericVar *base, int exp, NumericVar *result, int rscale)
NumericVar
base_prod
;
int
local_rscale
;
/* Detect some special cases, particularly 0^0. */
switch
(
exp
)
{
case
0
:
if
(
base
->
ndigits
==
0
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FLOATING_POINT_EXCEPTION
),
errmsg
(
"zero raised to zero is undefined"
)));
set_var_from_var
(
&
const_one
,
result
);
result
->
dscale
=
rscale
;
/* no need to round */
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录