Skip to content

Commit

Permalink
fix git conflict
Browse files Browse the repository at this point in the history
Signed-off-by: lance6716 <[email protected]>
  • Loading branch information
lance6716 committed Oct 23, 2023
1 parent 1924fa7 commit 8ee5acb
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 453 deletions.
6 changes: 6 additions & 0 deletions executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,8 @@ func (b *executorBuilder) buildLoadData(v *plannercore.LoadData) Executor {
isLoadData: true,
txnInUse: sync.Mutex{},
}
restrictive := b.ctx.GetSessionVars().SQLMode.HasStrictMode() &&
v.OnDuplicate != ast.OnDuplicateKeyHandlingIgnore
loadDataInfo := &LoadDataInfo{
row: make([]types.Datum, 0, len(insertVal.insertColumns)),
InsertValues: insertVal,
Expand All @@ -937,6 +939,10 @@ func (b *executorBuilder) buildLoadData(v *plannercore.LoadData) Executor {
ColumnAssignments: v.ColumnAssignments,
ColumnsAndUserVars: v.ColumnsAndUserVars,
Ctx: b.ctx,
restrictive: restrictive,
}
if !restrictive {
b.ctx.GetSessionVars().StmtCtx.DupKeyAsWarning = true
}
columnNames := loadDataInfo.initFieldMappings()
err := loadDataInfo.initLoadColumns(columnNames)
Expand Down
4 changes: 0 additions & 4 deletions executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2100,15 +2100,11 @@ func ResetContextOfStmt(ctx sessionctx.Context, s ast.StmtNode) (err error) {
sc.NoZeroDate = vars.SQLMode.HasNoZeroDateMode()
sc.TruncateAsWarning = !vars.StrictSQLMode
case *ast.LoadDataStmt:
<<<<<<< HEAD
sc.DupKeyAsWarning = true
sc.BadNullAsWarning = true
// With IGNORE or LOCAL, data-interpretation errors become warnings and the load operation continues,
// even if the SQL mode is restrictive. For details: https://dev.mysql.com/doc/refman/8.0/en/load-data.html
// TODO: since TiDB only support the LOCAL by now, so the TruncateAsWarning are always true here.
sc.TruncateAsWarning = true
=======
>>>>>>> 25770ffc6b9 (executor: unify replace into logic for InsertValues and ReplaceExec (#41947))
sc.InLoadDataStmt = true
// return warning instead of error when load data meet no partition for value
sc.IgnoreNoPartition = true
Expand Down
38 changes: 13 additions & 25 deletions executor/insert_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -1183,18 +1183,6 @@ func (e *InsertValues) batchCheckAndInsert(ctx context.Context, rows [][]types.D
for _, uk := range r.uniqueKeys {
_, err := txn.Get(ctx, uk.newKey)
if err == nil {
<<<<<<< HEAD
// If duplicate keys were found in BatchGet, mark row = nil.
e.ctx.GetSessionVars().StmtCtx.AppendWarning(uk.dupErr)
if txnCtx := e.ctx.GetSessionVars().TxnCtx; txnCtx.IsPessimistic {
// lock duplicated unique key on insert-ignore
txnCtx.AddUnchangedRowKey(uk.newKey)
}
skip = true
break
}
if !kv.IsErrNotFound(err) {
=======
if replace {
_, handle, err := tables.FetchDuplicatedHandle(
ctx,
Expand All @@ -1217,11 +1205,14 @@ func (e *InsertValues) batchCheckAndInsert(ctx context.Context, rows [][]types.D
} else {
// If duplicate keys were found in BatchGet, mark row = nil.
e.ctx.GetSessionVars().StmtCtx.AppendWarning(uk.dupErr)
if txnCtx := e.ctx.GetSessionVars().TxnCtx; txnCtx.IsPessimistic {
// lock duplicated unique key on insert-ignore
txnCtx.AddUnchangedRowKey(uk.newKey)
}
skip = true
break
}
} else if !kv.IsErrNotFound(err) {
>>>>>>> 25770ffc6b9 (executor: unify replace into logic for InsertValues and ReplaceExec (#41947))
return err
}
}
Expand Down Expand Up @@ -1270,28 +1261,25 @@ func (e *InsertValues) removeRow(
return false, err
}
if identical {
<<<<<<< HEAD
_, err := appendUnchangedRowForLock(e.ctx, r.t, handle, oldRow)
if err != nil {
return err
}
return nil
=======
if inReplace {
e.ctx.GetSessionVars().StmtCtx.AddAffectedRows(1)
}
_, err := appendUnchangedRowForLock(e.ctx, r.t, handle, oldRow)
if err != nil {
return false, err
}
return true, nil
>>>>>>> 25770ffc6b9 (executor: unify replace into logic for InsertValues and ReplaceExec (#41947))
}

err = r.t.RemoveRecord(e.ctx, handle, oldRow)
if err != nil {
return false, err
}
err = onRemoveRowForFK(e.ctx, oldRow, e.fkChecks, e.fkCascades)
if err != nil {
return false, err
}
// need https://github.com/pingcap/tidb/pull/40069
//err = onRemoveRowForFK(e.ctx, oldRow, e.fkChecks, e.fkCascades)
//if err != nil {
// return false, err
//}
if inReplace {
e.ctx.GetSessionVars().StmtCtx.AddAffectedRows(1)
} else {
Expand Down
Loading

0 comments on commit 8ee5acb

Please sign in to comment.