GenIndexKey generates storage key for index values. Returned distinct indicates whether the indexed values should be distinct in storage (i.e. whether handle is encoded in the key).
(ec errctx.Context, loc *time.Location, indexedValues []types.Datum, h kv.Handle, buf []byte)
| 94 | // GenIndexKey generates storage key for index values. Returned distinct indicates whether the |
| 95 | // indexed values should be distinct in storage (i.e. whether handle is encoded in the key). |
| 96 | func (c *index) GenIndexKey(ec errctx.Context, loc *time.Location, indexedValues []types.Datum, h kv.Handle, buf []byte) (key []byte, distinct bool, err error) { |
| 97 | idxTblID := c.phyTblID |
| 98 | fullHandle := h |
| 99 | if c.idxInfo.Global { |
| 100 | idxTblID = c.tblInfo.ID |
| 101 | pi := c.tblInfo.GetPartitionInfo() |
| 102 | if pi != nil && pi.NewTableID != 0 { |
| 103 | isNew, ok := pi.DDLChangedIndex[c.idxInfo.ID] |
| 104 | if ok && isNew { |
| 105 | idxTblID = pi.NewTableID |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | if _, ok := fullHandle.(kv.PartitionHandle); !ok && |
| 110 | c.idxInfo.GlobalIndexVersion >= model.GlobalIndexVersionV1 { |
| 111 | fullHandle = kv.NewPartitionHandle(c.phyTblID, h) |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | if err = c.castIndexValuesToChangingTypes(indexedValues); err != nil { |
| 116 | return |
| 117 | } |
| 118 | |
| 119 | key, distinct, err = tablecodec.GenIndexKey(loc, c.tblInfo, c.idxInfo, idxTblID, indexedValues, fullHandle, buf) |
| 120 | err = ec.HandleError(err) |
| 121 | return |
| 122 | } |
| 123 | |
| 124 | // GenIndexValue generates the index value. |
| 125 | func (c *index) GenIndexValue(ec errctx.Context, loc *time.Location, distinct, untouched bool, indexedValues []types.Datum, |
no test coverage detected