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

Function isVar

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

isVar returns true if the expression's value can vary during plan execution. The parameter allowConstPlaceholders should be true in the common case of scalar expressions that will be evaluated in the context of the execution of a prepared query, where the placeholder will have the same value for eve

(evalCtx *EvalContext, expr Expr, allowConstPlaceholders bool)

Source from the content-addressed store, hash-verified

922// It is set to false for scalar expressions that are not
923// evaluated as part of query execution, eg. DEFAULT expressions.
924func isVar(evalCtx *EvalContext, expr Expr, allowConstPlaceholders bool) bool {
925 switch expr.(type) {
926 case VariableExpr:
927 return true
928 case *Placeholder:
929 if allowConstPlaceholders {
930 if evalCtx == nil || !evalCtx.HasPlaceholders() {
931 // The placeholder cannot be resolved -- it is variable.
932 return true
933 }
934 return evalCtx.Placeholders.IsUnresolvedPlaceholder(expr)
935 }
936 // Placeholders considered always variable.
937 return true
938 }
939 return false
940}
941
942type containsVarsVisitor struct {
943 containsVars bool

Callers 4

normalizeMethod · 0.85
VisitPreMethod · 0.85
VisitPreMethod · 0.85
VisitPreMethod · 0.85

Calls 2

HasPlaceholdersMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…