GetTiDBAST extracts the TiDB AST from a base.AST. Returns the AST and true if it is a TiDB AST, nil and false otherwise. Also checks for PingCapASTProvider implementations (e.g. *OmniAST during the advisor migration), which lazily build a native pingcap AST on demand.
(a base.AST)
| 37 | // Also checks for PingCapASTProvider implementations (e.g. *OmniAST during |
| 38 | // the advisor migration), which lazily build a native pingcap AST on demand. |
| 39 | func GetTiDBAST(a base.AST) (*AST, bool) { |
| 40 | if a == nil { |
| 41 | return nil, false |
| 42 | } |
| 43 | if tidbAST, ok := a.(*AST); ok { |
| 44 | return tidbAST, true |
| 45 | } |
| 46 | if provider, ok := a.(PingCapASTProvider); ok { |
| 47 | return provider.AsPingCapAST() |
| 48 | } |
| 49 | return nil, false |
| 50 | } |