(outputOffset map[int64]int, handle kv.Handle, value []byte, cacheBytes []byte)
| 399 | } |
| 400 | |
| 401 | func (decoder *BytesDecoder) decodeToBytesInternal(outputOffset map[int64]int, handle kv.Handle, value []byte, cacheBytes []byte) ([][]byte, error) { |
| 402 | var r row |
| 403 | err := r.fromBytes(value) |
| 404 | if err != nil { |
| 405 | return nil, err |
| 406 | } |
| 407 | values := make([][]byte, len(outputOffset)) |
| 408 | for i := range decoder.columns { |
| 409 | col := &decoder.columns[i] |
| 410 | tp := fieldType2Flag(col.Ft.ArrayType().GetType(), col.Ft.GetFlag()&mysql.UnsignedFlag == 0) |
| 411 | colID := col.ID |
| 412 | offset := outputOffset[colID] |
| 413 | idx, isNil, notFound := r.findColID(colID) |
| 414 | if !notFound && !isNil { |
| 415 | val := r.getData(idx) |
| 416 | values[offset] = decoder.encodeOldDatum(tp, val) |
| 417 | continue |
| 418 | } |
| 419 | |
| 420 | // Only try to decode handle when there is no corresponding column in the value. |
| 421 | // This is because the information in handle may be incomplete in some cases. |
| 422 | // For example, prefixed clustered index like 'primary key(col1(1))' only store the leftmost 1 char in the handle. |
| 423 | if decoder.tryDecodeHandle(values, offset, col, handle, cacheBytes) { |
| 424 | continue |
| 425 | } |
| 426 | |
| 427 | if isNil { |
| 428 | values[offset] = []byte{NilFlag} |
| 429 | continue |
| 430 | } |
| 431 | |
| 432 | if decoder.defBytes != nil { |
| 433 | defVal, err := decoder.defBytes(i) |
| 434 | if err != nil { |
| 435 | return nil, err |
| 436 | } |
| 437 | if len(defVal) > 0 { |
| 438 | values[offset] = defVal |
| 439 | continue |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | values[offset] = []byte{NilFlag} |
| 444 | } |
| 445 | return values, nil |
| 446 | } |
| 447 | |
| 448 | func (decoder *BytesDecoder) tryDecodeHandle(values [][]byte, offset int, col *ColInfo, |
| 449 | handle kv.Handle, cacheBytes []byte) bool { |
no test coverage detected