code: func (c *index) Create(ctx sessionctx.Context, rm kv.RetrieverMutator, indexedValues []types.Datum, h int64,
  	opts ...*table.CreateIdxOpt) (int64, error) {
  	writeBufs := ctx.GetSessionVars().GetWriteStmtBufs()
  	skipCheck := ctx.GetSessionVars().LightningMode || ctx.GetSessionVars().StmtCtx.BatchCheck
  	key, distinct, err := c.GenIndexKey(ctx.GetSessionVars().StmtCtx, indexedValues, h, writeBufs.IndexKeyBuf)
  	if err != nil {
  		return 0, err
  	}
  	// save the key buffer to reuse.
  	writeBufs.IndexKeyBuf = key
  	if !distinct {
  		// non-unique index doesn't need store value, write a '0' to reduce space
  		err = rm.Set(key, []byte{'0'})
  		return 0, err
  	}
  
  	var value []byte
  	if !skipCheck {
  		value, err = rm.Get(key)
  	}
  
  	if skipCheck || kv.IsErrNotFound(err) {
  		err = rm.Set(key, EncodeHandle(h))
  		return 0, err
  	}
  
  	handle, err := DecodeHandle(value)
  	if err != nil {
  		return 0, err
  	}
  	return handle, kv.ErrKeyExists
  }
docs: // Create creates a new entry in the kvIndex data.
  // If the index is unique and there is an existing entry with the same key,
  // Create will return the existing entry's handle as the first return value, ErrKeyExists as the second return value.