EncodeMySQLTime encodes datum of `KindMysqlTime` to []byte.
(loc *time.Location, t types.Time, tp byte, b []byte)
| 192 | |
| 193 | // EncodeMySQLTime encodes datum of `KindMysqlTime` to []byte. |
| 194 | func EncodeMySQLTime(loc *time.Location, t types.Time, tp byte, b []byte) (_ []byte, err error) { |
| 195 | // Encoding timestamp need to consider timezone. If it's not in UTC, transform to UTC first. |
| 196 | // This is compatible with `PBToExpr > convertTime`, and coprocessor assumes the passed timestamp is in UTC as well. |
| 197 | if tp == mysql.TypeUnspecified { |
| 198 | tp = t.Type() |
| 199 | } |
| 200 | if tp == mysql.TypeTimestamp && loc != time.UTC { |
| 201 | err = t.ConvertTimeZone(loc, time.UTC) |
| 202 | if err != nil { |
| 203 | return nil, err |
| 204 | } |
| 205 | } |
| 206 | var v uint64 |
| 207 | v, err = t.ToPackedUint() |
| 208 | if err != nil { |
| 209 | return nil, err |
| 210 | } |
| 211 | b = EncodeUint(b, v) |
| 212 | return b, nil |
| 213 | } |
| 214 | |
| 215 | func encodeString(b []byte, val types.Datum, comparable1 bool) []byte { |
| 216 | if collate.NewCollationEnabled() && comparable1 { |