reverting some changes

This commit is contained in:
Shlomi Noach 2019-01-01 11:47:41 +02:00
parent 0be91ba0f2
commit 7c17cee010
2 changed files with 13 additions and 16 deletions

View File

@ -1002,6 +1002,7 @@ func (this *Applier) ApplyDMLEventQuery(dmlEvent *binlog.BinlogDMLEvent) error {
return err return err
} }
sessionQuery := `SET sessionQuery := `SET
SESSION time_zone = '+00:00',
sql_mode = CONCAT(@@session.sql_mode, ',STRICT_ALL_TABLES') sql_mode = CONCAT(@@session.sql_mode, ',STRICT_ALL_TABLES')
` `
if _, err := tx.Exec(sessionQuery); err != nil { if _, err := tx.Exec(sessionQuery); err != nil {
@ -1046,6 +1047,7 @@ func (this *Applier) ApplyDMLEventQueries(dmlEvents [](*binlog.BinlogDMLEvent))
} }
sessionQuery := `SET sessionQuery := `SET
SESSION time_zone = '+00:00',
sql_mode = CONCAT(@@session.sql_mode, ',STRICT_ALL_TABLES') sql_mode = CONCAT(@@session.sql_mode, ',STRICT_ALL_TABLES')
` `
if _, err := tx.Exec(sessionQuery); err != nil { if _, err := tx.Exec(sessionQuery); err != nil {

View File

@ -434,9 +434,7 @@ func (e *RowsEvent) decodeValue(data []byte, tp byte, meta uint16) (v interface{
} }
case MYSQL_TYPE_TIMESTAMP2: case MYSQL_TYPE_TIMESTAMP2:
v, n, err = decodeTimestamp2(data, meta, e.timestampStringLocation) v, n, err = decodeTimestamp2(data, meta, e.timestampStringLocation)
fmt.Printf("============= v0: %+v\n", v) //v = e.parseFracTime(v)
v = e.parseFracTime(v)
fmt.Printf("============= v1: %+v\n", v)
case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_DATETIME:
n = 8 n = 8
i64 := binary.LittleEndian.Uint64(data) i64 := binary.LittleEndian.Uint64(data)
@ -705,11 +703,8 @@ func decodeTimestamp2(data []byte, dec uint16, timestampStringLocation *time.Loc
return formatZeroTime(int(usec), int(dec)), n, nil return formatZeroTime(int(usec), int(dec)), n, nil
} }
return fracTime{ t := time.Unix(sec, usec*1000)
Time: time.Unix(sec, usec*1000), return t, n, nil
Dec: int(dec),
timestampStringLocation: timestampStringLocation,
}, n, nil
} }
const DATETIMEF_INT_OFS int64 = 0x8000000000 const DATETIMEF_INT_OFS int64 = 0x8000000000
@ -755,14 +750,14 @@ func decodeDatetime2(data []byte, dec uint16) (interface{}, int, error) {
minute := int((hms >> 6) % (1 << 6)) minute := int((hms >> 6) % (1 << 6))
hour := int((hms >> 12)) hour := int((hms >> 12))
// if frac != 0 { if frac != 0 {
// return fmt.Sprintf("%04d-%02d-%02d %02d:%02d:%02d.%06d", year, month, day, hour, minute, second, frac), n, nil // commented by Shlomi Noach. Yes I know about `git blame` return fmt.Sprintf("%04d-%02d-%02d %02d:%02d:%02d.%06d", year, month, day, hour, minute, second, frac), n, nil // commented by Shlomi Noach. Yes I know about `git blame`
// } }
// return fmt.Sprintf("%04d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, second), n, nil // commented by Shlomi Noach. Yes I know about `git blame` return fmt.Sprintf("%04d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, second), n, nil // commented by Shlomi Noach. Yes I know about `git blame`
return fracTime{ // return fracTime{
Time: time.Date(year, time.Month(month), day, hour, minute, second, int(frac*1000), time.UTC), // Time: time.Date(year, time.Month(month), day, hour, minute, second, int(frac*1000), time.UTC),
Dec: int(dec), // Dec: int(dec),
}, n, nil // }, n, nil
} }
const TIMEF_OFS int64 = 0x800000000000 const TIMEF_OFS int64 = 0x800000000000