Preprocess resolves table names of the node, and checks some statements' validation. preprocessReturn used to extract the infoschema for the tableName and the timestamp from the asof clause.
(ctx context.Context, sctx sessionctx.Context, node *resolve.NodeW, preprocessOpt ...PreprocessOpt)
| 125 | // Preprocess resolves table names of the node, and checks some statements' validation. |
| 126 | // preprocessReturn used to extract the infoschema for the tableName and the timestamp from the asof clause. |
| 127 | func Preprocess(ctx context.Context, sctx sessionctx.Context, node *resolve.NodeW, preprocessOpt ...PreprocessOpt) error { |
| 128 | defer tracing.StartRegion(ctx, "planner.Preprocess").End() |
| 129 | v := preprocessor{ |
| 130 | ctx: ctx, |
| 131 | sctx: sctx, |
| 132 | tableAliasInJoin: make([]map[string]any, 0), |
| 133 | preprocessWith: &preprocessWith{cteCanUsed: make([]string, 0), cteBeforeOffset: make([]int, 0)}, |
| 134 | lockSelectCtxStack: make([]lockSelectCtx, 0), |
| 135 | staleReadProcessor: staleread.NewStaleReadProcessor(ctx, sctx), |
| 136 | varsMutable: make(map[string]struct{}), |
| 137 | varsReadonly: make(map[string]struct{}), |
| 138 | resolveCtx: node.GetResolveContext(), |
| 139 | } |
| 140 | for _, optFn := range preprocessOpt { |
| 141 | optFn(&v) |
| 142 | } |
| 143 | // PreprocessorReturn must be non-nil before preprocessing |
| 144 | if v.PreprocessorReturn == nil { |
| 145 | v.PreprocessorReturn = &PreprocessorReturn{} |
| 146 | } |
| 147 | node.Node.Accept(&v) |
| 148 | // InfoSchema must be non-nil after preprocessing |
| 149 | v.ensureInfoSchema() |
| 150 | sctx.GetPlanCtx().SetReadonlyUserVarMap(v.varsReadonly) |
| 151 | if len(v.varsReadonly) > 0 { |
| 152 | sctx.GetSessionVars().StmtCtx.SetSkipPlanCache("read-only variables are used") |
| 153 | } |
| 154 | return errors.Trace(v.err) |
| 155 | } |
| 156 | |
| 157 | type preprocessorFlag uint64 |
| 158 |