mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
Fix estimate_expression_value to constant-fold SQLValueFunction nodes.
Oversight in my commit 0bb51aa96. 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.
This commit is contained in:
parent
eb68141688
commit
4e20511d5b
@ -3346,6 +3346,23 @@ eval_const_expressions_mutator(Node *node,
|
|||||||
newcoalesce->location = coalesceexpr->location;
|
newcoalesce->location = coalesceexpr->location;
|
||||||
return (Node *) newcoalesce;
|
return (Node *) newcoalesce;
|
||||||
}
|
}
|
||||||
|
case T_SQLValueFunction:
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* All variants of SQLValueFunction are stable, so if we are
|
||||||
|
* estimating the expression's value, we should evaluate the
|
||||||
|
* current function value. Otherwise just copy.
|
||||||
|
*/
|
||||||
|
SQLValueFunction *svf = (SQLValueFunction *) node;
|
||||||
|
|
||||||
|
if (context->estimate)
|
||||||
|
return (Node *) evaluate_expr((Expr *) svf,
|
||||||
|
svf->type,
|
||||||
|
svf->typmod,
|
||||||
|
InvalidOid);
|
||||||
|
else
|
||||||
|
return copyObject((Node *) svf);
|
||||||
|
}
|
||||||
case T_FieldSelect:
|
case T_FieldSelect:
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user