MCPcopy Create free account
hub / github.com/dolthub/doltgresql / dropProcedure

Function dropProcedure

server/node/drop_procedure.go:104–137  ·  view source on GitHub ↗
(ctx *sql.Context, procColl *procedures.Collection, fn *RoutineWithParams, ifExists bool)

Source from the content-addressed store, hash-verified

102}
103
104func dropProcedure(ctx *sql.Context, procColl *procedures.Collection, fn *RoutineWithParams, ifExists bool) error {
105 // TODO: provide db
106 schema, err := core.GetSchemaName(ctx, nil, fn.SchemaName)
107 if err != nil {
108 return err
109 }
110
111 var procId = id.NewProcedure(schema, fn.RoutineName)
112 if len(fn.Args) == 0 {
113 procs, err := procColl.GetProcedureOverloads(ctx, procId)
114 if err != nil {
115 return err
116 }
117 if len(procs) == 1 {
118 procId = procs[0].ID
119 } else if len(procs) > 1 {
120 procExists := procColl.HasProcedure(ctx, procId)
121 if !procExists {
122 return errors.Errorf(`procedure name "%s" is not unique`, fn.RoutineName)
123 }
124 }
125 } else {
126 var argTypes = make([]id.Type, len(fn.Args))
127 for i, arg := range fn.Args {
128 argTypes[i] = arg.Type.ID
129 }
130 procId = id.NewProcedure(schema, fn.RoutineName, argTypes...)
131 }
132 procExists := procColl.HasProcedure(ctx, procId)
133 if !procExists && ifExists {
134 return nil
135 }
136 return procColl.DropProcedure(ctx, procId)
137}

Callers 1

RowIterMethod · 0.85

Calls 6

GetSchemaNameFunction · 0.92
NewProcedureFunction · 0.92
GetProcedureOverloadsMethod · 0.80
HasProcedureMethod · 0.80
DropProcedureMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected