(ctx context.Context, txn kv.Transaction, uk *keyValueWithDupInfo, replace bool, r toBeCheckedRow)
| 1178 | } |
| 1179 | |
| 1180 | func (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. |
no test coverage detected