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

Commit9e4b213

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 parentbda2856 commit9e4b213

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
@@ -2758,14 +2758,18 @@ eval_const_expressions_mutator(Node *node,
27582758
/*
27592759
* We can remove null constants from the list. For a non-null
27602760
* constant, if it has not been preceded by any other
2761-
* non-null-constant expressions then that is the result.
2761+
* non-null-constant expressions then it is the result. Otherwise,
2762+
* it's the next argument, but we can drop following arguments
2763+
* since they will never be reached.
27622764
*/
27632765
if (IsA(e,Const))
27642766
{
27652767
if (((Const*)e)->constisnull)
27662768
continue;/* drop null constant */
27672769
if (newargs==NIL)
27682770
returne;/* first expr */
2771+
newargs=lappend(newargs,e);
2772+
break;
27692773
}
27702774
newargs=lappend(newargs,e);
27712775
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp