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)
| 922 | // It is set to false for scalar expressions that are not |
| 923 | // evaluated as part of query execution, eg. DEFAULT expressions. |
| 924 | func 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 | |
| 942 | type containsVarsVisitor struct { |
| 943 | containsVars bool |
no test coverage detected
searching dependent graphs…