MCPcopy
hub / github.com/pingcap/tidb / EncodeMySQLTime

Function EncodeMySQLTime

pkg/util/codec/codec.go:194–213  ·  view source on GitHub ↗

EncodeMySQLTime encodes datum of `KindMysqlTime` to []byte.

(loc *time.Location, t types.Time, tp byte, b []byte)

Source from the content-addressed store, hash-verified

192
193// EncodeMySQLTime encodes datum of `KindMysqlTime` to []byte.
194func 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
215func encodeString(b []byte, val types.Datum, comparable1 bool) []byte {
216 if collate.NewCollationEnabled() && comparable1 {

Callers 4

encodeDatumMethod · 0.92
datumExprFunction · 0.92
encodeFunction · 0.85
HashGroupKeyFunction · 0.85

Calls 4

EncodeUintFunction · 0.85
ConvertTimeZoneMethod · 0.80
ToPackedUintMethod · 0.80
TypeMethod · 0.65

Tested by 1

datumExprFunction · 0.74