MCPcopy Create free account
hub / github.com/cockroachdb/copyist / QueryContext

Method QueryContext

stmt.go:125–158  ·  view source on GitHub ↗

QueryContext executes a query that may return rows, such as a SELECT. QueryContext must honor the context timeout and return when it is canceled.

(
	ctx context.Context, args []driver.NamedValue,
)

Source from the content-addressed store, hash-verified

123//
124// QueryContext must honor the context timeout and return when it is canceled.
125func (s *proxyStmt) QueryContext(
126 ctx context.Context, args []driver.NamedValue,
127) (driver.Rows, error) {
128 if IsRecording() {
129 var rows driver.Rows
130 var err error
131 if stmtCtx, ok := s.stmt.(driver.StmtQueryContext); ok {
132 rows, err = stmtCtx.QueryContext(ctx, args)
133 } else {
134 var vals []driver.Value
135 vals, err = namedValueToValue(args)
136 if err != nil {
137 return nil, err
138 }
139 rows, err = s.stmt.Query(vals)
140 }
141
142 currentSession.AddRecord(&record{Typ: StmtQuery, Args: recordArgs{err}})
143 if err != nil {
144 return nil, err
145 }
146 return &proxyRows{rows: rows}, nil
147 }
148
149 rec, err := currentSession.VerifyRecord(StmtQuery)
150 if err != nil {
151 return nil, err
152 }
153 err, _ = rec.Args[0].(error)
154 if err != nil {
155 return nil, err
156 }
157 return &proxyRows{}, nil
158}
159
160func namedValueToValue(named []driver.NamedValue) ([]driver.Value, error) {
161 dargs := make([]driver.Value, len(named))

Callers

nothing calls this directly

Calls 5

IsRecordingFunction · 0.85
namedValueToValueFunction · 0.85
QueryMethod · 0.80
AddRecordMethod · 0.80
VerifyRecordMethod · 0.80

Tested by

no test coverage detected