Skip to content

Commit

Permalink
executor: remove some useless code and avoid some redundancy check (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jackysp authored Oct 12, 2018
1 parent 508a836 commit d7a59ec
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 153 deletions.
18 changes: 9 additions & 9 deletions executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,15 +538,15 @@ func (b *executorBuilder) buildInsert(v *plannercore.Insert) Executor {
baseExec.initCap = chunk.ZeroCapacity

ivs := &InsertValues{
baseExecutor: baseExec,
Table: v.Table,
Columns: v.Columns,
Lists: v.Lists,
SetList: v.SetList,
GenColumns: v.GenCols.Columns,
GenExprs: v.GenCols.Exprs,
needFillDefaultValues: v.NeedFillDefaultValue,
SelectExec: selectExec,
baseExecutor: baseExec,
Table: v.Table,
Columns: v.Columns,
Lists: v.Lists,
SetList: v.SetList,
GenColumns: v.GenCols.Columns,
GenExprs: v.GenCols.Exprs,
hasRefCols: v.NeedFillDefaultValue,
SelectExec: selectExec,
}

if v.IsReplace {
Expand Down
9 changes: 0 additions & 9 deletions executor/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,11 @@ type DeleteExec struct {
// `delete from t as t1, t as t2`, the same table has two alias, we have to identify a table
// by its alias instead of ID.
tblMap map[int64][]*ast.TableName

finished bool
}

// Next implements the Executor Next interface.
func (e *DeleteExec) Next(ctx context.Context, chk *chunk.Chunk) error {
chk.Reset()
if e.finished {
return nil
}
defer func() {
e.finished = true
}()

if e.IsMultiTable {
return errors.Trace(e.deleteMultiTablesByChunk(ctx))
}
Expand Down
6 changes: 6 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,12 @@ func (s *testSuite) TestGeneratedColumnRead(c *C) {
result = tk.MustQuery(`SELECT * FROM test_gc_read WHERE d = 12`)
result.Check(testkit.Rows(`3 4 7 12`))

tk.MustExec(`INSERT INTO test_gc_read set a = 4, b = d + 1`)
result = tk.MustQuery(`SELECT * FROM test_gc_read ORDER BY a`)
result.Check(testkit.Rows(`0 <nil> <nil> <nil>`, `1 2 3 2`, `3 4 7 12`,
`4 <nil> <nil> <nil>`, `8 8 16 64`))
tk.MustExec(`DELETE FROM test_gc_read where a = 4`)

// Test on-conditions on virtual/stored generated columns.
tk.MustExec(`CREATE TABLE test_gc_help(a int primary key, b int, c int, d int)`)
tk.MustExec(`INSERT INTO test_gc_help(a, b, c, d) SELECT * FROM test_gc_read`)
Expand Down
5 changes: 0 additions & 5 deletions executor/insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type InsertExec struct {
*InsertValues
OnDuplicate []*expression.Assignment
Priority mysql.PriorityEnum
finished bool
}

func (e *InsertExec) exec(rows [][]types.Datum) error {
Expand Down Expand Up @@ -68,7 +67,6 @@ func (e *InsertExec) exec(rows [][]types.Datum) error {
}
}
}
e.finished = true
return nil
}

Expand Down Expand Up @@ -131,9 +129,6 @@ func (e *InsertExec) batchUpdateDupRows(newRows [][]types.Datum) error {
// Next implements Exec Next interface.
func (e *InsertExec) Next(ctx context.Context, chk *chunk.Chunk) error {
chk.Reset()
if e.finished {
return nil
}
cols, err := e.getColumns(e.Table.Cols())
if err != nil {
return errors.Trace(err)
Expand Down
Loading

0 comments on commit d7a59ec

Please sign in to comment.