RunAnalyzeQuery analyzes a statement either on the running transaction or on the temporal read-only transaction.
(ctx context.Context, stmt spanner.Statement)
| 248 | |
| 249 | // RunAnalyzeQuery analyzes a statement either on the running transaction or on the temporal read-only transaction. |
| 250 | func (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 | |
| 268 | func (s *Session) runQueryWithOptions(ctx context.Context, stmt spanner.Statement, opts spanner.QueryOptions) (*spanner.RowIterator, *spanner.ReadOnlyTransaction) { |
| 269 | if s.InReadWriteTransaction() { |
no test coverage detected