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

Commitfaea083

Browse files
committed
Fix old oversight in const-simplification of COALESCE() expressions.
Once we have found a non-null constant argument, there is no need toexamine additional arguments of the COALESCE. The previous coding got itright only if the constant was in the first argument position; otherwiseit tried to simplify following arguments too, leading to unexpectedbehavior like this:regression=# select coalesce(f1, 42, 1/0) from int4_tbl;ERROR: division by zeroIt's a minor corner case, but a bug is a bug, so back-patch all the way.
1 parentf5cf3ce commitfaea083

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

‎src/backend/optimizer/util/clauses.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1774,14 +1774,18 @@ eval_const_expressions_mutator(Node *node,
17741774
/*
17751775
* We can remove null constants from the list. For a non-null
17761776
* constant, if it has not been preceded by any other
1777-
* non-null-constant expressions then that is the result.
1777+
* non-null-constant expressions then it is the result. Otherwise,
1778+
* it's the next argument, but we can drop following arguments
1779+
* since they will never be reached.
17781780
*/
17791781
if (IsA(e,Const))
17801782
{
17811783
if (((Const*)e)->constisnull)
17821784
continue;/* drop null constant */
17831785
if (newargs==NIL)
17841786
returne;/* first expr */
1787+
newargs=lappend(newargs,e);
1788+
break;
17851789
}
17861790
newargs=lappend(newargs,e);
17871791
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp