MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / NormalizeExpr

Method NormalizeExpr

pkg/sql/sem/tree/normalize.go:677–684  ·  view source on GitHub ↗

NormalizeExpr normalizes a typed expression, simplifying where possible, but guaranteeing that the result of evaluating the expression is unchanged and that resulting expression tree is still well-typed. Example normalizations: (a) -> a a = 1 + 1 -> a = 2 a + 1 = 2

(typedExpr TypedExpr)

Source from the content-addressed store, hash-verified

675// a BETWEEN b AND c -> (a >= b) AND (a <= c)
676// a NOT BETWEEN b AND c -> (a < b) OR (a > c)
677func (ctx *EvalContext) NormalizeExpr(typedExpr TypedExpr) (TypedExpr, error) {
678 v := MakeNormalizeVisitor(ctx)
679 expr, _ := WalkExpr(&v, typedExpr)
680 if v.err != nil {
681 return nil, v.err
682 }
683 return expr.(TypedExpr), nil
684}
685
686// NormalizeVisitor supports the execution of NormalizeExpr.
687type NormalizeVisitor struct {

Callers 2

TestNormalizeExprFunction · 0.95
normalizeMethod · 0.80

Calls 2

MakeNormalizeVisitorFunction · 0.85
WalkExprFunction · 0.85

Tested by 1

TestNormalizeExprFunction · 0.76