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

Commitd730424

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 parent19e231b commitd730424

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
@@ -2746,14 +2746,18 @@ eval_const_expressions_mutator(Node *node,
27462746
/*
27472747
* We can remove null constants from the list. For a non-null
27482748
* constant, if it has not been preceded by any other
2749-
* non-null-constant expressions then that is the result.
2749+
* non-null-constant expressions then it is the result. Otherwise,
2750+
* it's the next argument, but we can drop following arguments
2751+
* since they will never be reached.
27502752
*/
27512753
if (IsA(e,Const))
27522754
{
27532755
if (((Const*)e)->constisnull)
27542756
continue;/* drop null constant */
27552757
if (newargs==NIL)
27562758
returne;/* first expr */
2759+
newargs=lappend(newargs,e);
2760+
break;
27572761
}
27582762
newargs=lappend(newargs,e);
27592763
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp