mirror of
https://github.com/postgres/postgres.git
synced 2025-08-25 20:23:07 +03:00
Replace SQLValueFunction by COERCE_SQL_SYNTAX
This switch impacts 9 patterns related to a SQL-mandated special syntax
for function calls:
- LOCALTIME [ ( typmod ) ]
- LOCALTIMESTAMP [ ( typmod ) ]
- CURRENT_TIME [ ( typmod ) ]
- CURRENT_TIMESTAMP [ ( typmod ) ]
- CURRENT_DATE
Five new entries are added to pg_proc to compensate the removal of
SQLValueFunction to provide backward-compatibility and making this
change transparent for the end-user (for example for the attribute
generated when a keyword is specified in a SELECT or in a FROM clause
without an alias, or when specifying something else than an Iconst to
the parser).
The parser included a set of checks coming from the files in charge of
holding the C functions used for the SQLValueFunction calls (as of
transformSQLValueFunction()), which are now moved within each function's
execution path, so this reduces the dependencies between the execution
and the parsing steps. As of this change, all the SQL keywords use the
same paths for their work, relying only on COERCE_SQL_SYNTAX. Like
fb32748
, no performance difference has been noticed, while the perf
profiles get reduced with ExecEvalSQLValueFunction() gone.
Bump catalog version.
Reviewed-by: Corey Huinker, Ted Yu
Discussion: https://postgr.es/m/YzaG3MoryCguUOym@paquier.xyz
This commit is contained in:
@@ -4603,7 +4603,6 @@ cost_qual_eval_walker(Node *node, cost_qual_eval_context *context)
|
||||
}
|
||||
}
|
||||
else if (IsA(node, MinMaxExpr) ||
|
||||
IsA(node, SQLValueFunction) ||
|
||||
IsA(node, XmlExpr) ||
|
||||
IsA(node, CoerceToDomain) ||
|
||||
IsA(node, NextValueExpr))
|
||||
|
@@ -383,12 +383,6 @@ contain_mutable_functions_walker(Node *node, void *context)
|
||||
context))
|
||||
return true;
|
||||
|
||||
if (IsA(node, SQLValueFunction))
|
||||
{
|
||||
/* all variants of SQLValueFunction are stable */
|
||||
return true;
|
||||
}
|
||||
|
||||
if (IsA(node, NextValueExpr))
|
||||
{
|
||||
/* NextValueExpr is volatile */
|
||||
@@ -537,8 +531,8 @@ contain_volatile_functions_walker(Node *node, void *context)
|
||||
|
||||
/*
|
||||
* See notes in contain_mutable_functions_walker about why we treat
|
||||
* MinMaxExpr, XmlExpr, and CoerceToDomain as immutable, while
|
||||
* SQLValueFunction is stable. Hence, none of them are of interest here.
|
||||
* MinMaxExpr, XmlExpr, and CoerceToDomain as immutable. Hence, none of
|
||||
* them are of interest here.
|
||||
*/
|
||||
|
||||
/* Recurse to check arguments */
|
||||
@@ -583,10 +577,9 @@ contain_volatile_functions_not_nextval_walker(Node *node, void *context)
|
||||
|
||||
/*
|
||||
* See notes in contain_mutable_functions_walker about why we treat
|
||||
* MinMaxExpr, XmlExpr, and CoerceToDomain as immutable, while
|
||||
* SQLValueFunction is stable. Hence, none of them are of interest here.
|
||||
* Also, since we're intentionally ignoring nextval(), presumably we
|
||||
* should ignore NextValueExpr.
|
||||
* MinMaxExpr, XmlExpr, and CoerceToDomain as immutable. Hence, none of
|
||||
* them are of interest here. Also, since we're intentionally ignoring
|
||||
* nextval(), presumably we should ignore NextValueExpr.
|
||||
*/
|
||||
|
||||
/* Recurse to check arguments */
|
||||
@@ -732,8 +725,8 @@ max_parallel_hazard_walker(Node *node, max_parallel_hazard_context *context)
|
||||
* (Note: in principle that's wrong because a domain constraint could
|
||||
* contain a parallel-unsafe function; but useful constraints probably
|
||||
* never would have such, and assuming they do would cripple use of
|
||||
* parallel query in the presence of domain types.) SQLValueFunction
|
||||
* should be safe in all cases. NextValueExpr is parallel-unsafe.
|
||||
* parallel query in the presence of domain types.) NextValueExpr is
|
||||
* parallel-unsafe.
|
||||
*/
|
||||
if (IsA(node, CoerceToDomain))
|
||||
{
|
||||
@@ -1180,7 +1173,6 @@ contain_leaked_vars_walker(Node *node, void *context)
|
||||
case T_CaseExpr:
|
||||
case T_CaseTestExpr:
|
||||
case T_RowExpr:
|
||||
case T_SQLValueFunction:
|
||||
case T_NullTest:
|
||||
case T_BooleanTest:
|
||||
case T_NextValueExpr:
|
||||
@@ -3194,23 +3186,6 @@ eval_const_expressions_mutator(Node *node,
|
||||
newcoalesce->location = coalesceexpr->location;
|
||||
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:
|
||||
{
|
||||
/*
|
||||
|
Reference in New Issue
Block a user