(ctx context.Context, session *Session)
| 922 | } |
| 923 | |
| 924 | func (s *ExplainAnalyzeDmlStatement) Execute(ctx context.Context, session *Session) (*Result, error) { |
| 925 | stmt := spanner.NewStatement(s.Dml) |
| 926 | |
| 927 | affectedRows, timestamp, queryPlan, _, err := runInNewOrExistRwTxForExplain(ctx, session, func() (int64, *pb.QueryPlan, *pb.ResultSetMetadata, error) { |
| 928 | iter, _ := session.RunQueryWithStats(ctx, stmt) |
| 929 | defer iter.Stop() |
| 930 | err := iter.Do(func(r *spanner.Row) error { return nil }) |
| 931 | if err != nil { |
| 932 | return 0, nil, nil, err |
| 933 | } |
| 934 | return iter.RowCount, iter.QueryPlan, iter.Metadata, nil |
| 935 | }) |
| 936 | if err != nil { |
| 937 | return nil, err |
| 938 | } |
| 939 | |
| 940 | rows, predicates, err := processPlanWithStats(queryPlan) |
| 941 | if err != nil { |
| 942 | return nil, err |
| 943 | } |
| 944 | result := &Result{ |
| 945 | IsMutation: true, |
| 946 | ColumnNames: explainAnalyzeColumnNames, |
| 947 | ForceVerbose: true, |
| 948 | AffectedRows: int(affectedRows), |
| 949 | Rows: rows, |
| 950 | Predicates: predicates, |
| 951 | Timestamp: timestamp, |
| 952 | } |
| 953 | |
| 954 | return result, nil |
| 955 | } |
| 956 | |
| 957 | // runInNewOrExistRwTxForExplain is a helper function for runAnalyzeQuery and ExplainAnalyzeDmlStatement. |
| 958 | // It execute a function in the current RW transaction or an implicit RW transaction. |
nothing calls this directly
no test coverage detected