nodeDropFunction handles *tree.DropFunction nodes.
(ctx *Context, node *tree.DropFunction)
| 25 | |
| 26 | // nodeDropFunction handles *tree.DropFunction nodes. |
| 27 | func nodeDropFunction(ctx *Context, node *tree.DropFunction) (vitess.Statement, error) { |
| 28 | if node == nil { |
| 29 | return nil, nil |
| 30 | } |
| 31 | |
| 32 | if node.DropBehavior == tree.DropCascade { |
| 33 | return nil, fmt.Errorf("DROP FUNCTION with CASCADE is not supported yet") |
| 34 | } |
| 35 | |
| 36 | if len(node.Functions) == 0 { |
| 37 | return nil, fmt.Errorf("no function name specified for DROP FUNCTION") |
| 38 | } |
| 39 | |
| 40 | functions := make([]*pgnodes.RoutineWithParams, len(node.Functions)) |
| 41 | for i, fn := range node.Functions { |
| 42 | var args []pgnodes.RoutineParam |
| 43 | for _, a := range fn.Args { |
| 44 | if a.Mode != tree.RoutineArgModeOut { |
| 45 | _, dt, err := nodeResolvableTypeReference(ctx, a.Type, false) |
| 46 | if err != nil { |
| 47 | return nil, err |
| 48 | } |
| 49 | args = append(args, pgnodes.RoutineParam{ |
| 50 | Name: a.Name.String(), |
| 51 | Type: dt, |
| 52 | }) |
| 53 | } |
| 54 | } |
| 55 | objName := fn.Name.ToTableName() |
| 56 | functions[i] = &pgnodes.RoutineWithParams{ |
| 57 | Args: args, |
| 58 | SchemaName: objName.Schema(), |
| 59 | RoutineName: objName.Object(), |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | return vitess.InjectedStatement{ |
| 64 | Statement: pgnodes.NewDropFunction( |
| 65 | node.IfExists, |
| 66 | functions, |
| 67 | node.DropBehavior == tree.DropCascade), |
| 68 | Children: nil, |
| 69 | }, nil |
| 70 | } |
no test coverage detected