Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

privilege/privileges: don't reuse chunk in loadTable function #6976

Merged
merged 3 commits into from
Jul 4, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hardly saw "WARNNING" in codebase, but Note or NOTE.

// 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