Skip to content

Commit 4e20511

Browse files
committed
Fix estimate_expression_value to constant-fold SQLValueFunction nodes.
Oversight in my commit 0bb51aa. Noted while poking at a recent bug report --- HEAD's estimates for a query using CURRENT_DATE were unexpectedly much worse than 9.6's.
1 parent eb68141 commit 4e20511

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/backend/optimizer/util/clauses.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3346,6 +3346,23 @@ eval_const_expressions_mutator(Node *node,
33463346
newcoalesce->location = coalesceexpr->location;
33473347
return (Node *) newcoalesce;
33483348
}
3349+
case T_SQLValueFunction:
3350+
{
3351+
/*
3352+
* All variants of SQLValueFunction are stable, so if we are
3353+
* estimating the expression's value, we should evaluate the
3354+
* current function value. Otherwise just copy.
3355+
*/
3356+
SQLValueFunction *svf = (SQLValueFunction *) node;
3357+
3358+
if (context->estimate)
3359+
return (Node *) evaluate_expr((Expr *) svf,
3360+
svf->type,
3361+
svf->typmod,
3362+
InvalidOid);
3363+
else
3364+
return copyObject((Node *) svf);
3365+
}
33493366
case T_FieldSelect:
33503367
{
33513368
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy