nodeExplain handles *tree.Explain nodes.
(ctx *Context, node *tree.Explain)
| 24 | |
| 25 | // nodeExplain handles *tree.Explain nodes. |
| 26 | func nodeExplain(ctx *Context, node *tree.Explain) (vitess.Statement, error) { |
| 27 | if node == nil { |
| 28 | return nil, nil |
| 29 | } |
| 30 | |
| 31 | if node.TableName != nil { |
| 32 | tableName, err := nodeUnresolvedObjectName(ctx, node.TableName) |
| 33 | if err != nil { |
| 34 | return nil, err |
| 35 | } |
| 36 | |
| 37 | var showTableOpts *vitess.ShowTablesOpt |
| 38 | if node.AsOf != nil { |
| 39 | asOf, err := nodeExpr(ctx, node.AsOf.Expr) |
| 40 | if err != nil { |
| 41 | return nil, err |
| 42 | } |
| 43 | showTableOpts = &vitess.ShowTablesOpt{ |
| 44 | AsOf: asOf, |
| 45 | SchemaName: tableName.SchemaQualifier.String(), |
| 46 | DbName: tableName.DbQualifier.String(), |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | show := &vitess.Show{ |
| 51 | Type: "columns", |
| 52 | Table: tableName, |
| 53 | ShowTablesOpt: showTableOpts, |
| 54 | } |
| 55 | |
| 56 | return show, nil |
| 57 | } |
| 58 | |
| 59 | if stmt, ok := node.Statement.(*tree.Select); ok { |
| 60 | // TODO: read tree.ExplainOptions |
| 61 | selectStmt, err := nodeSelect(ctx, stmt) |
| 62 | if err != nil { |
| 63 | return nil, err |
| 64 | } |
| 65 | explain := &vitess.Explain{ |
| 66 | ExplainFormat: vitess.TreeStr, |
| 67 | Statement: selectStmt, |
| 68 | } |
| 69 | return explain, nil |
| 70 | } |
| 71 | |
| 72 | return nil, errors.Errorf("This EXPLAIN syntax is not yet supported") |
| 73 | } |
no test coverage detected