MCPcopy Index your code
hub / github.com/cloudspannerecosystem/spanner-cli / RunAnalyzeQuery

Method RunAnalyzeQuery

session.go:250–266  ·  view source on GitHub ↗

RunAnalyzeQuery analyzes a statement either on the running transaction or on the temporal read-only transaction.

(ctx context.Context, stmt spanner.Statement)

Source from the content-addressed store, hash-verified

248
249// RunAnalyzeQuery analyzes a statement either on the running transaction or on the temporal read-only transaction.
250func (s *Session) RunAnalyzeQuery(ctx context.Context, stmt spanner.Statement) (*pb.QueryPlan, *pb.ResultSetMetadata, error) {
251 mode := pb.ExecuteSqlRequest_PLAN
252 opts := spanner.QueryOptions{
253 Mode: &mode,
254 Priority: s.currentPriority(),
255 }
256 iter, _ := s.runQueryWithOptions(ctx, stmt, opts)
257
258 // Need to read rows from iterator to get the query plan.
259 err := iter.Do(func(r *spanner.Row) error {
260 return nil
261 })
262 if err != nil {
263 return nil, nil, err
264 }
265 return iter.QueryPlan, iter.Metadata, nil
266}
267
268func (s *Session) runQueryWithOptions(ctx context.Context, stmt spanner.Statement, opts spanner.QueryOptions) (*spanner.RowIterator, *spanner.ReadOnlyTransaction) {
269 if s.InReadWriteTransaction() {

Callers 1

runAnalyzeQueryFunction · 0.80

Calls 2

currentPriorityMethod · 0.95
runQueryWithOptionsMethod · 0.95

Tested by

no test coverage detected