MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / helpWithFunction

Function helpWithFunction

pkg/sql/parser/help.go:92–133  ·  view source on GitHub ↗

helpWithFunction is to be used in parser actions to mark the parser "in error", with the error set to a contextual help message about the current built-in function.

(sqllex sqlLexer, f tree.ResolvableFunctionReference)

Source from the content-addressed store, hash-verified

90// "in error", with the error set to a contextual help message about
91// the current built-in function.
92func helpWithFunction(sqllex sqlLexer, f tree.ResolvableFunctionReference) int {
93 d, err := f.Resolve(sessiondata.SearchPath{})
94 if err != nil {
95 return 1
96 }
97
98 msg := HelpMessage{
99 Function: f.String(),
100 HelpMessageBody: HelpMessageBody{
101 Category: d.Category,
102 SeeAlso: DocsURL("functions-and-operators.html"),
103 },
104 }
105
106 var buf bytes.Buffer
107 w := tabwriter.NewWriter(&buf, 0, 0, 1, ' ', 0)
108
109 // Each function definition contains one or more overloads. We need
110 // to extract them all; moreover each overload may have a different
111 // documentation, so we need to also combine the descriptions
112 // together.
113 lastInfo := ""
114 for i, overload := range d.Definition {
115 b := overload.(*tree.Overload)
116 if b.Info != "" && b.Info != lastInfo {
117 if i > 0 {
118 fmt.Fprintln(w, "---")
119 }
120 fmt.Fprintf(w, "\n%s\n\n", b.Info)
121 fmt.Fprintln(w, "Signature")
122 }
123 lastInfo = b.Info
124
125 simplifyRet := d.Class == tree.GeneratorClass
126 fmt.Fprintf(w, "%s%s\n", d.Name, b.Signature(simplifyRet))
127 }
128 _ = w.Flush()
129 msg.Text = buf.String()
130
131 sqllex.(*lexer).SetHelp(msg)
132 return 1
133}
134
135func helpWithFunctionByName(sqllex sqlLexer, s string) int {
136 un := &tree.UnresolvedName{NumParts: 1, Parts: tree.NameParts{s}}

Callers 2

ParseMethod · 0.85
helpWithFunctionByNameFunction · 0.85

Calls 6

FlushMethod · 0.95
DocsURLFunction · 0.85
SignatureMethod · 0.80
SetHelpMethod · 0.80
ResolveMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…