nodeCall handles *tree.Call nodes.
(ctx *Context, node *tree.Call)
| 26 | |
| 27 | // nodeCall handles *tree.Call nodes. |
| 28 | func nodeCall(ctx *Context, node *tree.Call) (vitess.Statement, error) { |
| 29 | if node == nil { |
| 30 | return nil, nil |
| 31 | } |
| 32 | if node.Procedure.Type != 0 { |
| 33 | return nil, errors.Errorf("procedure distinction is not yet supported") |
| 34 | } |
| 35 | if node.Procedure.Filter != nil { |
| 36 | return nil, errors.Errorf("procedure filters are not yet supported") |
| 37 | } |
| 38 | if node.Procedure.WindowDef != nil { |
| 39 | return nil, errors.Errorf("procedure window definitions are not yet supported") |
| 40 | } |
| 41 | if node.Procedure.AggType == tree.OrderedSetAgg { |
| 42 | return nil, errors.Errorf("procedure aggregation is not yet supported") |
| 43 | } |
| 44 | if len(node.Procedure.OrderBy) > 0 { |
| 45 | return nil, errors.Errorf("procedure ORDER BY is not yet supported") |
| 46 | } |
| 47 | |
| 48 | ctx.Auth().PushAuthType(auth.AuthType_EXECUTE) |
| 49 | defer ctx.Auth().PopAuthType() |
| 50 | |
| 51 | var qualifier vitess.TableIdent |
| 52 | var name vitess.ColIdent |
| 53 | switch funcRef := node.Procedure.Func.FunctionReference.(type) { |
| 54 | case *tree.FunctionDefinition: |
| 55 | name = vitess.NewColIdent(funcRef.Name) |
| 56 | case *tree.UnresolvedName: |
| 57 | if funcRef.NumParts > 2 { |
| 58 | return nil, errors.Errorf("referencing items outside the schema or database is not yet supported") |
| 59 | } |
| 60 | if funcRef.NumParts == 2 { |
| 61 | qualifier = vitess.NewTableIdent(funcRef.Parts[1]) |
| 62 | } |
| 63 | name = vitess.NewColIdent(funcRef.Parts[0]) |
| 64 | default: |
| 65 | return nil, errors.Errorf("unknown function reference") |
| 66 | } |
| 67 | exprs, err := nodeExprs(ctx, node.Procedure.Exprs) |
| 68 | if err != nil { |
| 69 | return nil, err |
| 70 | } |
| 71 | return vitess.InjectedStatement{ |
| 72 | Statement: pgnodes.NewCall(qualifier.String(), name.String(), exprs), |
| 73 | Children: exprs, |
| 74 | Auth: vitess.AuthInformation{ |
| 75 | AuthType: auth.AuthType_EXECUTE, |
| 76 | TargetType: auth.AuthTargetType_FunctionIdentifiers, |
| 77 | TargetNames: []string{qualifier.String(), name.String()}, |
| 78 | // TODO: need to get argument types separated by comma ( check routineArgTypesKey function ) |
| 79 | Extra: "", |
| 80 | }, |
| 81 | }, nil |
| 82 | } |
no test coverage detected