Skip to content

Commit

Permalink
privilege/privileges: don't reuse chunk in loadTable function
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao committed Jul 4, 2018
1 parent 1f6e12c commit 04d3d7e
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 {
// WARNNING: 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 04d3d7e

Please sign in to comment.