Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
2da3742c
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,发现更多精彩内容 >>
提交
2da3742c
编写于
6月 15, 2002
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a little more material to the new section about evaluation order.
上级
eb1ad5b4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
6 deletion
+25
-6
doc/src/sgml/syntax.sgml
doc/src/sgml/syntax.sgml
+25
-6
未找到文件。
doc/src/sgml/syntax.sgml
浏览文件 @
2da3742c
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.6
1 2002/06/01 20:56:55 petere
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.6
2 2002/06/15 21:28:55 tgl
Exp $
-->
<chapter id="sql-syntax">
...
...
@@ -1435,14 +1435,13 @@ FROM states;
<para>
The order of evaluation of subexpressions is not defined. In
particular, subexpressions are not necessarily evaluated
left-to-right, right-to-left, or according to the lexical
precedence rules.
particular, the inputs of an operator or function are not necessarily
evaluated left-to-right or in any other fixed order.
</para>
<para>
Furthermore, if the result of an expression can be determined by
evaluating only some parts of it, then
some
subexpressions
evaluating only some parts of it, then
other
subexpressions
might not be evaluated at all. For instance, if one wrote
<programlisting>
SELECT true OR somefunc();
...
...
@@ -1459,7 +1458,27 @@ SELECT somefunc() OR true;
<para>
As a consequence, it is unwise to use functions with side effects
as part of complex expressions.
as part of complex expressions. It is particularly dangerous to
rely on side effects or evaluation order in WHERE and HAVING clauses,
since those clauses are extensively reprocessed as part of
developing an execution plan. Boolean
expressions (AND/OR/NOT combinations) in those clauses may be reorganized
in any manner allowed by the laws of Boolean algebra.
</para>
<para>
When it is essential to force evaluation order, a CASE construct may
be used. For example, this is an untrustworthy way of trying to
avoid division by zero in a WHERE clause:
<programlisting>
SELECT ... WHERE x <> 0 AND y/x > 1.5;
</programlisting>
but this is safe:
<programlisting>
SELECT ... WHERE CASE WHEN x <> 0 THEN y/x > 1.5 ELSE false END;
</programlisting>
A CASE construct used in this fashion will defeat optimization attempts,
so it should only be done when necessary.
</para>
</sect2>
</sect1>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录