(col *ColInfo, colData []byte)
| 100 | } |
| 101 | |
| 102 | func (decoder *DatumMapDecoder) decodeColDatum(col *ColInfo, colData []byte) (types.Datum, error) { |
| 103 | var d types.Datum |
| 104 | switch col.Ft.GetType() { |
| 105 | case mysql.TypeLonglong, mysql.TypeLong, mysql.TypeInt24, mysql.TypeShort, mysql.TypeTiny: |
| 106 | if mysql.HasUnsignedFlag(col.Ft.GetFlag()) { |
| 107 | d.SetUint64(decodeUint(colData)) |
| 108 | } else { |
| 109 | d.SetInt64(decodeInt(colData)) |
| 110 | } |
| 111 | case mysql.TypeYear: |
| 112 | d.SetInt64(decodeInt(colData)) |
| 113 | case mysql.TypeFloat: |
| 114 | _, fVal, err := codec.DecodeFloat(colData) |
| 115 | if err != nil { |
| 116 | return d, err |
| 117 | } |
| 118 | d.SetFloat32(float32(fVal)) |
| 119 | case mysql.TypeDouble: |
| 120 | _, fVal, err := codec.DecodeFloat(colData) |
| 121 | if err != nil { |
| 122 | return d, err |
| 123 | } |
| 124 | d.SetFloat64(fVal) |
| 125 | case mysql.TypeVarString, mysql.TypeVarchar, mysql.TypeString, mysql.TypeBlob, mysql.TypeTinyBlob, mysql.TypeMediumBlob, mysql.TypeLongBlob: |
| 126 | d.SetString(string(colData), col.Ft.GetCollate()) |
| 127 | case mysql.TypeNewDecimal: |
| 128 | _, dec, precision, frac, err := codec.DecodeDecimal(colData) |
| 129 | if err != nil { |
| 130 | return d, err |
| 131 | } |
| 132 | d.SetMysqlDecimal(dec) |
| 133 | d.SetLength(precision) |
| 134 | d.SetFrac(frac) |
| 135 | case mysql.TypeDate, mysql.TypeDatetime, mysql.TypeTimestamp: |
| 136 | var t types.Time |
| 137 | t.SetType(col.Ft.GetType()) |
| 138 | t.SetFsp(col.Ft.GetDecimal()) |
| 139 | err := t.FromPackedUint(decodeUint(colData)) |
| 140 | if err != nil { |
| 141 | return d, err |
| 142 | } |
| 143 | if col.Ft.GetType() == mysql.TypeTimestamp && !t.IsZero() { |
| 144 | err = t.ConvertTimeZone(time.UTC, decoder.loc) |
| 145 | if err != nil { |
| 146 | return d, err |
| 147 | } |
| 148 | } |
| 149 | d.SetMysqlTime(t) |
| 150 | case mysql.TypeDuration: |
| 151 | var dur types.Duration |
| 152 | dur.Duration = time.Duration(decodeInt(colData)) |
| 153 | dur.Fsp = col.Ft.GetDecimal() |
| 154 | d.SetMysqlDuration(dur) |
| 155 | case mysql.TypeEnum: |
| 156 | // ignore error deliberately, to read empty enum value. |
| 157 | enum, err := types.ParseEnumValue(col.Ft.GetElems(), decodeUint(colData)) |
| 158 | if err != nil { |
| 159 | enum = types.Enum{} |
no test coverage detected