code: func (e *InsertExec) batchUpdateDupRows(newRows [][]types.Datum) error {
  	err := e.batchGetInsertKeys(e.ctx, e.Table, newRows)
  	if err != nil {
  		return err
  	}
  
  	// Batch get the to-be-updated rows in storage.
  	err = e.initDupOldRowValue(e.ctx, e.Table, newRows)
  	if err != nil {
  		return err
  	}
  
  	for i, r := range e.toBeCheckedRows {
  		if r.handleKey != nil {
  			if _, found := e.dupKVs[string(r.handleKey.newKV.key)]; found {
  				handle, err := tablecodec.DecodeRowKey(r.handleKey.newKV.key)
  				if err != nil {
  					return err
  				}
  				err = e.updateDupRow(r, handle, e.OnDuplicate)
  				if err != nil {
  					return err
  				}
  				continue
  			}
  		}
  		for _, uk := range r.uniqueKeys {
  			if val, found := e.dupKVs[string(uk.newKV.key)]; found {
  				handle, err := tables.DecodeHandle(val)
  				if err != nil {
  					return err
  				}
  				err = e.updateDupRow(r, handle, e.OnDuplicate)
  				if err != nil {
  					return err
  				}
  				newRows[i] = nil
  				break
  			}
  		}
  		// If row was checked with no duplicate keys,
  		// we should do insert the row,
  		// and key-values should be filled back to dupOldRowValues for the further row check,
  		// due to there may be duplicate keys inside the insert statement.
  		if newRows[i] != nil {
  			newHandle, err := e.addRecord(newRows[i])
  			if err != nil {
  				return err
  			}
  			e.fillBackKeys(e.Table, r, newHandle)
  		}
  	}
  	return nil
  }
docs: // batchUpdateDupRows updates multi-rows in batch if they are duplicate with rows in table.