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

Function Parse

server/plpgsql/parse.go:26–52  ·  view source on GitHub ↗

Parse parses the given CREATE FUNCTION string (which must be the entire string, not just the body) into a Block containing the contents of the body.

(fullCreateFunctionString string)

Source from the content-addressed store, hash-verified

24// Parse parses the given CREATE FUNCTION string (which must be the entire string, not just the body) into a Block
25// containing the contents of the body.
26func Parse(fullCreateFunctionString string) ([]InterpreterOperation, error) {
27 var functions []function
28 parsedBody, err := pg_query.ParsePlPgSqlToJSON(fullCreateFunctionString)
29 if err != nil {
30 return nil, err
31 }
32 err = json.Unmarshal([]byte(parsedBody), &functions)
33 if err != nil {
34 return nil, err
35 }
36 if len(functions) != 1 {
37 return nil, errors.New("CREATE FUNCTION parsed multiple blocks")
38 }
39 block, err := jsonConvert(functions[0].Function)
40 if err != nil {
41 return nil, err
42 }
43 ops := make([]InterpreterOperation, 0, len(block.Body)+len(block.Variables))
44 stack := NewInterpreterStack(nil)
45 if err = block.AppendOperations(&ops, &stack); err != nil {
46 return nil, err
47 }
48 if err = reconcileLabels(ops); err != nil {
49 return nil, err
50 }
51 return ops, nil
52}

Callers 5

UpdateFieldMethod · 0.92
UpdateFieldMethod · 0.92
nodeCreateFunctionFunction · 0.92
nodeCreateProcedureFunction · 0.92
nodeCreateTriggerFunction · 0.92

Calls 5

jsonConvertFunction · 0.85
NewInterpreterStackFunction · 0.85
reconcileLabelsFunction · 0.85
UnmarshalMethod · 0.65
AppendOperationsMethod · 0.65

Tested by

no test coverage detected