Skip to content

Commit

Permalink
privilege/privileges: don't reuse chunk in loadTable function (#6976)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao authored and shenli committed Jul 4, 2018
1 parent 9d49f83 commit 1310996
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions privilege/privileges/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,19 @@ func (p *MySQLPrivilege) loadTable(sctx sessionctx.Context, sql string,
defer terror.Call(rs.Close)

fs := rs.Fields()
chk := rs.NewChunk()
it := chunk.NewIterator4Chunk(chk)
for {
// NOTE: decodeTableRow decodes data from a chunk Row, that is a shallow copy.
// The result will reference memory in the chunk, so the chunk must not be reused
// here, otherwise some werid bug will happen!
chk := rs.NewChunk()
err = rs.Next(context.TODO(), chk)
if err != nil {
return errors.Trace(err)
}
if chk.NumRows() == 0 {
return nil
}
it := chunk.NewIterator4Chunk(chk)
for row := it.Begin(); row != it.End(); row = it.Next() {
err = decodeTableRow(row, fs)
if err != nil {
Expand Down

0 comments on commit 1310996

Please sign in to comment.