nodeSelect handles *tree.Select nodes.
(ctx *Context, node *tree.Select)
| 27 | |
| 28 | // nodeSelect handles *tree.Select nodes. |
| 29 | func nodeSelect(ctx *Context, node *tree.Select) (vitess.SelectStatement, error) { |
| 30 | if node == nil { |
| 31 | return nil, nil |
| 32 | } |
| 33 | if node.Select == nil { |
| 34 | node.Select = &tree.ValuesClause{ |
| 35 | Rows: []tree.Exprs{}, |
| 36 | } |
| 37 | } |
| 38 | selectStmt, err := nodeSelectStatement(ctx, node.Select) |
| 39 | if err != nil { |
| 40 | return nil, err |
| 41 | } |
| 42 | orderBy, err := nodeOrderBy(ctx, node.OrderBy) |
| 43 | if err != nil { |
| 44 | return nil, err |
| 45 | } |
| 46 | with, err := nodeWith(ctx, node.With) |
| 47 | if err != nil { |
| 48 | return nil, err |
| 49 | } |
| 50 | limit, err := nodeLimit(ctx, node.Limit) |
| 51 | if err != nil { |
| 52 | return nil, err |
| 53 | } |
| 54 | _, err = nodeLockingClause(ctx, node.Locking) |
| 55 | if err != nil { |
| 56 | return nil, err |
| 57 | } |
| 58 | |
| 59 | switch selectStmt := selectStmt.(type) { |
| 60 | case *vitess.ParenSelect: |
| 61 | return selectStmt, nil |
| 62 | case *vitess.Select: |
| 63 | selectStmt.OrderBy = orderBy |
| 64 | selectStmt.With = with |
| 65 | selectStmt.Limit = limit |
| 66 | return selectStmt, nil |
| 67 | case *vitess.SetOp: |
| 68 | selectStmt.OrderBy = orderBy |
| 69 | selectStmt.With = with |
| 70 | selectStmt.Limit = limit |
| 71 | return selectStmt, nil |
| 72 | default: |
| 73 | return nil, errors.Errorf("SELECT has encountered an unknown clause: `%T`", selectStmt) |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | // nodeSelectStatement handles tree.SelectStatement nodes. |
| 78 | func nodeSelectStatement(ctx *Context, node tree.SelectStatement) (vitess.SelectStatement, error) { |
no test coverage detected