@@ -196,60 +196,43 @@ func (e *PointGetExecutor) get(key kv.Key) (val []byte, err error) {
196
196
}
197
197
198
198
func (e * PointGetExecutor ) decodeRowValToChunk (rowVal []byte , chk * chunk.Chunk ) error {
199
- // One column could be filled for multi-times in the schema. e.g. select b, b, c, c from t where a = 1.
200
- // We need to set the positions in the schema for the same column.
201
- colID2DecodedPos := make (map [int64 ]int , e .schema .Len ())
202
- decodedPos2SchemaPos := make ([][]int , 0 , e .schema .Len ())
203
- for schemaPos , col := range e .schema .Columns {
204
- if decodedPos , ok := colID2DecodedPos [col .ID ]; ! ok {
205
- colID2DecodedPos [col .ID ] = len (colID2DecodedPos )
206
- decodedPos2SchemaPos = append (decodedPos2SchemaPos , []int {schemaPos })
207
- } else {
208
- decodedPos2SchemaPos [decodedPos ] = append (decodedPos2SchemaPos [decodedPos ], schemaPos )
199
+ colID2CutPos := make (map [int64 ]int , e .schema .Len ())
200
+ for _ , col := range e .schema .Columns {
201
+ if _ , ok := colID2CutPos [col .ID ]; ! ok {
202
+ colID2CutPos [col .ID ] = len (colID2CutPos )
209
203
}
210
204
}
211
- decodedVals , err := tablecodec .CutRowNew (rowVal , colID2DecodedPos )
205
+ cutVals , err := tablecodec .CutRowNew (rowVal , colID2CutPos )
212
206
if err != nil {
213
207
return err
214
208
}
215
- if decodedVals == nil {
216
- decodedVals = make ([][]byte , len (colID2DecodedPos ))
209
+ if cutVals == nil {
210
+ cutVals = make ([][]byte , len (colID2CutPos ))
217
211
}
218
212
decoder := codec .NewDecoder (chk , e .ctx .GetSessionVars ().Location ())
219
- for id , decodedPos := range colID2DecodedPos {
220
- schemaPoses := decodedPos2SchemaPos [decodedPos ]
221
- firstPos := schemaPoses [0 ]
222
- if e .tblInfo .PKIsHandle && mysql .HasPriKeyFlag (e .schema .Columns [firstPos ].RetType .Flag ) {
223
- chk .AppendInt64 (firstPos , e .handle )
224
- // Fill other positions.
225
- for i := 1 ; i < len (schemaPoses ); i ++ {
226
- chk .MakeRef (firstPos , schemaPoses [i ])
227
- }
213
+ for i , col := range e .schema .Columns {
214
+ if e .tblInfo .PKIsHandle && mysql .HasPriKeyFlag (col .RetType .Flag ) {
215
+ chk .AppendInt64 (i , e .handle )
228
216
continue
229
217
}
230
- // ExtraHandleID is added when building plan, we can make sure that there's only one column's ID is this.
231
- if id == model .ExtraHandleID {
232
- chk .AppendInt64 (firstPos , e .handle )
218
+ if col .ID == model .ExtraHandleID {
219
+ chk .AppendInt64 (i , e .handle )
233
220
continue
234
221
}
235
- if len ( decodedVals [ decodedPos ]) == 0 {
236
- // This branch only entered for updating and deleting. It won't have one column in multiple positions.
237
- colInfo := getColInfoByID (e .tblInfo , id )
222
+ cutPos := colID2CutPos [ col . ID ]
223
+ if len ( cutVals [ cutPos ]) == 0 {
224
+ colInfo := getColInfoByID (e .tblInfo , col . ID )
238
225
d , err1 := table .GetColOriginDefaultValue (e .ctx , colInfo )
239
226
if err1 != nil {
240
227
return err1
241
228
}
242
- chk .AppendDatum (firstPos , & d )
229
+ chk .AppendDatum (i , & d )
243
230
continue
244
231
}
245
- _ , err = decoder .DecodeOne (decodedVals [ decodedPos ], firstPos , e . schema . Columns [ firstPos ] .RetType )
232
+ _ , err = decoder .DecodeOne (cutVals [ cutPos ], i , col .RetType )
246
233
if err != nil {
247
234
return err
248
235
}
249
- // Fill other positions.
250
- for i := 1 ; i < len (schemaPoses ); i ++ {
251
- chk .MakeRef (firstPos , schemaPoses [i ])
252
- }
253
236
}
254
237
return nil
255
238
}
0 commit comments