Expand description
Plan-time constant folding for SqlExpr.
Evaluates literal expressions and registered zero-or-few-arg scalar
functions (e.g. now(), current_timestamp, date_add(now(), '1h'))
at plan time via the shared nodedb_query::functions::eval_function
evaluator.
This keeps the bare-SELECT projection path, the INSERT/UPSERT
VALUES path, and any future default-expression paths from drifting
apart — they all reach the same evaluator that the Data Plane uses
for column-reference evaluation.
Semantics: Postgres / SQL-standard compatible. now() and
current_timestamp snapshot once per statement — CURRENT_TIMESTAMP
is defined to return the same value for every row of a single
statement, and Postgres goes further (same value for the whole
transaction). Folding at plan time satisfies both contracts and is
cheaper than per-row runtime dispatch.
Enums§
- Fold
Scope - Whether a fold is allowed to evaluate
Volatilefunctions.
Functions§
- default_
registry - Access the shared default registry.
- fold_
constant - Fold a
SqlExprto a literalSqlValueat plan time. SeeFoldResultfor what each outcome means. Volatile calls are never folded. - fold_
constant_ default - Convenience wrapper around
fold_constantusing the default registry. - fold_
constant_ scoped - Fold a
SqlExprunder an explicitFoldScope. - fold_
function_ call - Fold a function call by recursively folding its arguments, dispatching
through the shared scalar evaluator, and converting the result back to
SqlValue. Only folds functions that are present inregistry, so callers can distinguish “unknown function” from “known function, all args folded”. AVolatilefunction is never folded. - fold_
function_ call_ scoped - Fold a function call under an explicit
FoldScope.
Type Aliases§
- Fold
Result - Outcome of folding a constant expression.