Skip to content

Commit

Permalink
executor: generate fields in chunkRowRecordSet lazily (#37156)
Browse files Browse the repository at this point in the history
ref #36049
  • Loading branch information
sticnarf authored Aug 17, 2022
1 parent 5a4c14c commit d5ce00e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,9 @@ type chunkRowRecordSet struct {
}

func (c *chunkRowRecordSet) Fields() []*ast.ResultField {
if c.fields == nil {
c.fields = colNames2ResultFields(c.e.Schema(), c.execStmt.OutputNames, c.execStmt.Ctx.GetSessionVars().CurrentDB)
}
return c.fields
}

Expand Down Expand Up @@ -671,8 +674,7 @@ func (a *ExecStmt) runPessimisticSelectForUpdate(ctx context.Context, e Executor
break
}
if req.NumRows() == 0 {
fields := colNames2ResultFields(e.Schema(), a.OutputNames, a.Ctx.GetSessionVars().CurrentDB)
return &chunkRowRecordSet{rows: rows, fields: fields, e: e, execStmt: a}, nil
return &chunkRowRecordSet{rows: rows, e: e, execStmt: a}, nil
}
iter := chunk.NewIterator4Chunk(req)
for r := iter.Begin(); r != iter.End(); r = iter.Next() {
Expand Down

0 comments on commit d5ce00e

Please sign in to comment.