MCPcopy Create free account
hub / github.com/cloudspannerecosystem/spanner-cli / Execute

Method Execute

statement.go:543–567  ·  view source on GitHub ↗

Execute processes `EXPLAIN` statement for queries and DMLs.

(ctx context.Context, session *Session)

Source from the content-addressed store, hash-verified

541
542// Execute processes `EXPLAIN` statement for queries and DMLs.
543func (s *ExplainStatement) Execute(ctx context.Context, session *Session) (*Result, error) {
544 queryPlan, timestamp, _, err := runAnalyzeQuery(ctx, session, spanner.NewStatement(s.Explain), s.IsDML)
545 if err != nil {
546 return nil, err
547 }
548
549 if queryPlan == nil {
550 return nil, errors.New("EXPLAIN statement is not supported for Cloud Spanner Emulator.")
551 }
552
553 rows, predicates, err := processPlanWithoutStats(queryPlan)
554 if err != nil {
555 return nil, err
556 }
557
558 result := &Result{
559 ColumnNames: explainColumnNames,
560 AffectedRows: len(rows),
561 Rows: rows,
562 Timestamp: timestamp,
563 Predicates: predicates,
564 }
565
566 return result, nil
567}
568
569type DescribeStatement struct {
570 Statement string

Callers

nothing calls this directly

Calls 2

runAnalyzeQueryFunction · 0.85
processPlanWithoutStatsFunction · 0.85

Tested by

no test coverage detected