MCPcopy
hub / github.com/pingcap/tidb / ParseParameterizedSQL

Function ParseParameterizedSQL

pkg/planner/core/plan_cache_param.go:192–205  ·  view source on GitHub ↗

ParseParameterizedSQL parse this parameterized SQL with the specified sctx.

(sctx sessionctx.Context, paramSQL string)

Source from the content-addressed store, hash-verified

190
191// ParseParameterizedSQL parse this parameterized SQL with the specified sctx.
192func ParseParameterizedSQL(sctx sessionctx.Context, paramSQL string) (ast.StmtNode, error) {
193 p := parserPool.Get().(*parser.Parser)
194 defer parserPool.Put(p)
195 p.SetSQLMode(sctx.GetSessionVars().SQLMode)
196 p.SetParserConfig(sctx.GetSessionVars().BuildParserConfig())
197 tmp, _, err := p.ParseSQL(paramSQL, sctx.GetSessionVars().GetParseParams()...)
198 if err != nil {
199 return nil, err
200 }
201 if len(tmp) != 1 {
202 return nil, errors.New("unexpected multiple statements")
203 }
204 return tmp[0], nil
205}

Callers 1

Calls 9

SetParserConfigMethod · 0.80
BuildParserConfigMethod · 0.80
GetParseParamsMethod · 0.80
GetMethod · 0.65
PutMethod · 0.65
GetSessionVarsMethod · 0.65
ParseSQLMethod · 0.65
NewMethod · 0.65
SetSQLModeMethod · 0.45

Tested by

no test coverage detected