Skip to content

Commit a84cce1

Browse files
jackyspngaut
authored andcommitted
executor: remove some useless code and avoid some redundancy check (#7639) (#7881)
1 parent deea24f commit a84cce1

File tree

12 files changed

+172
-153
lines changed

12 files changed

+172
-153
lines changed

executor/builder.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -538,15 +538,15 @@ func (b *executorBuilder) buildInsert(v *plannercore.Insert) Executor {
538538
baseExec.initCap = chunk.ZeroCapacity
539539

540540
ivs := &InsertValues{
541-
baseExecutor: baseExec,
542-
Table: v.Table,
543-
Columns: v.Columns,
544-
Lists: v.Lists,
545-
SetList: v.SetList,
546-
GenColumns: v.GenCols.Columns,
547-
GenExprs: v.GenCols.Exprs,
548-
needFillDefaultValues: v.NeedFillDefaultValue,
549-
SelectExec: selectExec,
541+
baseExecutor: baseExec,
542+
Table: v.Table,
543+
Columns: v.Columns,
544+
Lists: v.Lists,
545+
SetList: v.SetList,
546+
GenColumns: v.GenCols.Columns,
547+
GenExprs: v.GenCols.Exprs,
548+
hasRefCols: v.NeedFillDefaultValue,
549+
SelectExec: selectExec,
550550
}
551551

552552
if v.IsReplace {

executor/delete.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,11 @@ type DeleteExec struct {
3939
// `delete from t as t1, t as t2`, the same table has two alias, we have to identify a table
4040
// by its alias instead of ID.
4141
tblMap map[int64][]*ast.TableName
42-
43-
finished bool
4442
}
4543

4644
// Next implements the Executor Next interface.
4745
func (e *DeleteExec) Next(ctx context.Context, chk *chunk.Chunk) error {
4846
chk.Reset()
49-
if e.finished {
50-
return nil
51-
}
52-
defer func() {
53-
e.finished = true
54-
}()
55-
5647
if e.IsMultiTable {
5748
return errors.Trace(e.deleteMultiTablesByChunk(ctx))
5849
}

executor/executor_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,12 @@ func (s *testSuite) TestGeneratedColumnRead(c *C) {
14511451
result = tk.MustQuery(`SELECT * FROM test_gc_read WHERE d = 12`)
14521452
result.Check(testkit.Rows(`3 4 7 12`))
14531453

1454+
tk.MustExec(`INSERT INTO test_gc_read set a = 4, b = d + 1`)
1455+
result = tk.MustQuery(`SELECT * FROM test_gc_read ORDER BY a`)
1456+
result.Check(testkit.Rows(`0 <nil> <nil> <nil>`, `1 2 3 2`, `3 4 7 12`,
1457+
`4 <nil> <nil> <nil>`, `8 8 16 64`))
1458+
tk.MustExec(`DELETE FROM test_gc_read where a = 4`)
1459+
14541460
// Test on-conditions on virtual/stored generated columns.
14551461
tk.MustExec(`CREATE TABLE test_gc_help(a int primary key, b int, c int, d int)`)
14561462
tk.MustExec(`INSERT INTO test_gc_help(a, b, c, d) SELECT * FROM test_gc_read`)

executor/insert.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ type InsertExec struct {
3131
*InsertValues
3232
OnDuplicate []*expression.Assignment
3333
Priority mysql.PriorityEnum
34-
finished bool
3534
}
3635

3736
func (e *InsertExec) exec(rows [][]types.Datum) error {
@@ -68,7 +67,6 @@ func (e *InsertExec) exec(rows [][]types.Datum) error {
6867
}
6968
}
7069
}
71-
e.finished = true
7270
return nil
7371
}
7472

@@ -131,9 +129,6 @@ func (e *InsertExec) batchUpdateDupRows(newRows [][]types.Datum) error {
131129
// Next implements Exec Next interface.
132130
func (e *InsertExec) Next(ctx context.Context, chk *chunk.Chunk) error {
133131
chk.Reset()
134-
if e.finished {
135-
return nil
136-
}
137132
cols, err := e.getColumns(e.Table.Cols())
138133
if err != nil {
139134
return errors.Trace(err)

0 commit comments

Comments
 (0)