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

Commit6f19a8c

Browse files
committed
Teach eval_const_expressions to constant-fold LEAST/GREATEST expressions.
Doing this requires an assumption that the invoked btree comparisonfunction is immutable. We could check that explicitly, but in otherplaces such as contain_mutable_functions we just assume that it's true,so we may as well do likewise here. (If the comparison function'sbehavior isn't immutable, the sort order in indexes built with it wouldbe unstable, so it seems certainly wrong for it not to be so.)Vik FearingDiscussion:https://postgr.es/m/c6e8504c-4c43-35fa-6c8f-3c0b80a912cc@2ndquadrant.com
1 parente0ef136 commit6f19a8c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3378,11 +3378,16 @@ eval_const_expressions_mutator(Node *node,
33783378
caseT_ArrayRef:
33793379
caseT_ArrayExpr:
33803380
caseT_RowExpr:
3381+
caseT_MinMaxExpr:
33813382
{
33823383
/*
33833384
* Generic handling for node types whose own processing is
33843385
* known to be immutable, and for which we need no smarts
33853386
* beyond "simplify if all inputs are constants".
3387+
*
3388+
* Treating MinMaxExpr this way amounts to assuming that the
3389+
* btree comparison function it calls is immutable; see the
3390+
* reasoning in contain_mutable_functions_walker.
33863391
*/
33873392

33883393
/* Copy the node and const-simplify its arguments */
@@ -3783,7 +3788,7 @@ eval_const_expressions_mutator(Node *node,
37833788
caseT_ConvertRowtypeExpr:
37843789
{
37853790
ConvertRowtypeExpr*cre=castNode(ConvertRowtypeExpr,node);
3786-
Node*arg;
3791+
Node*arg;
37873792
ConvertRowtypeExpr*newcre;
37883793

37893794
arg=eval_const_expressions_mutator((Node*)cre->arg,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp