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

Method ComBind

server/doltgres_handler.go:110–138  ·  view source on GitHub ↗

ComBind implements the Handler interface.

(ctx context.Context, c *mysql.Conn, query string, parsedQuery mysql.ParsedQuery, bindVars BindVariables, formatCodes []int16)

Source from the content-addressed store, hash-verified

108
109// ComBind implements the Handler interface.
110func (h *DoltgresHandler) ComBind(ctx context.Context, c *mysql.Conn, query string, parsedQuery mysql.ParsedQuery, bindVars BindVariables, formatCodes []int16) (mysql.BoundQuery, []pgproto3.FieldDescription, error) {
111 sqlCtx, err := h.sm.NewContextWithQuery(ctx, c, query)
112 if err != nil {
113 return nil, nil, err
114 }
115
116 stmt, ok := parsedQuery.(sqlparser.Statement)
117 if !ok {
118 return nil, nil, errors.Errorf("parsedQuery must be a sqlparser.Statement, but got %T", parsedQuery)
119 }
120
121 bvs, err := h.convertBindParameters(sqlCtx, bindVars.varTypes, bindVars.formatCodes, bindVars.parameters)
122 if err != nil {
123 if printErrorStackTraces {
124 fmt.Printf("unable to convert bind params: %+v\n", err)
125 }
126 return nil, nil, err
127 }
128
129 queryPlan, err := h.e.BoundQueryPlan(sqlCtx, query, stmt, bvs)
130 if err != nil {
131 if printErrorStackTraces {
132 fmt.Printf("unable to bind query plan: %+v\n", err)
133 }
134 return nil, nil, err
135 }
136 fields, err := schemaToFieldDescriptions(sqlCtx, queryPlan.Schema(sqlCtx), formatCodes)
137 return queryPlan, fields, err
138}
139
140// ComExecuteBound implements the Handler interface.
141func (h *DoltgresHandler) ComExecuteBound(ctx context.Context, conn *mysql.Conn, query string, boundQuery mysql.BoundQuery, formatCodes []int16, callback func(*sql.Context, *Result) error) error {

Callers

nothing calls this directly

Calls 5

convertBindParametersMethod · 0.95
PrintfMethod · 0.80
ErrorfMethod · 0.65
SchemaMethod · 0.65

Tested by

no test coverage detected