MCPcopy
hub / github.com/sqlc-dev/sqlc / dropFunction

Method dropFunction

internal/sql/catalog/func.go:96–122  ·  view source on GitHub ↗
(stmt *ast.DropFunctionStmt)

Source from the content-addressed store, hash-verified

94}
95
96func (c *Catalog) dropFunction(stmt *ast.DropFunctionStmt) error {
97 for _, spec := range stmt.Funcs {
98 ns := spec.Name.Schema
99 if ns == "" {
100 ns = c.DefaultSchema
101 }
102 s, err := c.getSchema(ns)
103 if errors.Is(err, sqlerr.NotFound) && stmt.MissingOk {
104 continue
105 } else if err != nil {
106 return err
107 }
108 var idx int
109 if spec.HasArgs {
110 _, idx, err = s.getFunc(spec.Name, spec.Args)
111 } else {
112 _, idx, err = s.getFuncByName(spec.Name)
113 }
114 if errors.Is(err, sqlerr.NotFound) && stmt.MissingOk {
115 continue
116 } else if err != nil {
117 return err
118 }
119 s.Funcs = append(s.Funcs[:idx], s.Funcs[idx+1:]...)
120 }
121 return nil
122}

Callers 1

UpdateMethod · 0.95

Calls 3

getSchemaMethod · 0.95
getFuncMethod · 0.80
getFuncByNameMethod · 0.80

Tested by

no test coverage detected