Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
D3Hunter committed May 11, 2023
1 parent 270cd47 commit 8586481
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions br/pkg/lightning/backend/kv/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ func (e *BaseKVEncoder) LogEvalGenExprFailed(row []types.Datum, colInfo *model.C
)
}

// TruncateWarns resets the warnings in session context.
func (e *BaseKVEncoder) TruncateWarns() {
e.SessionCtx.Vars.StmtCtx.TruncateWarnings(0)
}

func evalGeneratedColumns(se *Session, record []types.Datum, cols []*table.Column,
genCols []GeneratedCol) (errCol *model.ColumnInfo, err error) {
mutRow := chunk.MutRowFromDatums(record)
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/lightning/backend/kv/sql2kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (kvcodec *tableKVEncoder) Encode(row []types.Datum,
// row []types.Datum share the same underlying buf, and when doing CastValue, we're using hack.String/hack.Slice.
// when generating error such as mysql.ErrDataOutOfRange, the data will be part of the error, causing the buf
// unable to release. So we truncate the warnings here.
defer kvcodec.SessionCtx.Vars.StmtCtx.TruncateWarnings(0)
defer kvcodec.TruncateWarns()
var value types.Datum
var err error

Expand Down
5 changes: 5 additions & 0 deletions executor/importer/kv_encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ func newTableKVEncoder(

// Encode implements the kvEncoder interface.
func (en *tableKVEncoder) Encode(row []types.Datum, rowID int64) (*kv.Pairs, error) {
// we ignore warnings when encoding rows now, but warnings uses the same memory as parser, since the input
// row []types.Datum share the same underlying buf, and when doing CastValue, we're using hack.String/hack.Slice.
// when generating error such as mysql.ErrDataOutOfRange, the data will be part of the error, causing the buf
// unable to release. So we truncate the warnings here.
defer en.TruncateWarns()
record, err := en.parserData2TableData(row, rowID)
if err != nil {
return nil, err
Expand Down

0 comments on commit 8586481

Please sign in to comment.