MCPcopy Index your code
hub / github.com/pingcap/tidb / handleDuplicateKey

Method handleDuplicateKey

pkg/executor/insert_common.go:1180–1196  ·  view source on GitHub ↗
(ctx context.Context, txn kv.Transaction, uk *keyValueWithDupInfo, replace bool, r toBeCheckedRow)

Source from the content-addressed store, hash-verified

1178}
1179
1180func (e *InsertValues) handleDuplicateKey(ctx context.Context, txn kv.Transaction, uk *keyValueWithDupInfo, replace bool, r toBeCheckedRow) (bool, error) {
1181 if !replace {
1182 e.Ctx().GetSessionVars().StmtCtx.AppendWarning(uk.dupErr)
1183 if txnCtx := e.Ctx().GetSessionVars().TxnCtx; txnCtx.IsPessimistic && e.Ctx().GetSessionVars().LockUnchangedKeys {
1184 txnCtx.AddUnchangedKeyForLock(uk.newKey, false)
1185 }
1186 return true, nil
1187 }
1188 _, handle, err := tables.FetchDuplicatedHandle(ctx, uk.newKey, true, txn)
1189 if err != nil {
1190 return false, err
1191 }
1192 if handle == nil {
1193 return false, nil
1194 }
1195 return e.removeRow(ctx, txn, handle, r, true)
1196}
1197
1198// batchCheckAndInsert checks rows with duplicate errors.
1199// All duplicate rows will be ignored and appended as duplicate warnings.

Callers 1

batchCheckAndInsertMethod · 0.95

Calls 6

removeRowMethod · 0.95
FetchDuplicatedHandleFunction · 0.92
AppendWarningMethod · 0.65
GetSessionVarsMethod · 0.65
CtxMethod · 0.45

Tested by

no test coverage detected