restoring original row_event code; tampering with applier time_zone based on global timze_zone
This commit is contained in:
parent
a8f75f73ba
commit
5de8a010df
@ -48,7 +48,7 @@ func main() {
|
|||||||
flag.IntVar(&migrationContext.InspectorConnectionConfig.Key.Port, "port", 3306, "MySQL port (preferably a replica, not the master)")
|
flag.IntVar(&migrationContext.InspectorConnectionConfig.Key.Port, "port", 3306, "MySQL port (preferably a replica, not the master)")
|
||||||
flag.StringVar(&migrationContext.CliUser, "user", "", "MySQL user")
|
flag.StringVar(&migrationContext.CliUser, "user", "", "MySQL user")
|
||||||
flag.StringVar(&migrationContext.CliPassword, "password", "", "MySQL password")
|
flag.StringVar(&migrationContext.CliPassword, "password", "", "MySQL password")
|
||||||
flag.StringVar(&migrationContext.TimeZone, "time-zone", "+00:00", "assume timezone. Default: UTC. Set empty for system time zone")
|
flag.StringVar(&migrationContext.TimeZone, "time-zone", "", "assume timezone. Default: MySQL server global time zone.")
|
||||||
flag.StringVar(&migrationContext.ConfigFile, "conf", "", "Config file")
|
flag.StringVar(&migrationContext.ConfigFile, "conf", "", "Config file")
|
||||||
|
|
||||||
flag.StringVar(&migrationContext.DatabaseName, "database", "", "database name (mandatory)")
|
flag.StringVar(&migrationContext.DatabaseName, "database", "", "database name (mandatory)")
|
||||||
|
@ -56,6 +56,9 @@ func (this *Inspector) InitDBConnections() (err error) {
|
|||||||
if err := this.applyBinlogFormat(); err != nil {
|
if err := this.applyBinlogFormat(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := this.validateAndReadTimeZone(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,6 +158,18 @@ func (this *Inspector) validateConnection() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validateAndReadTimeZone potentially reads server time-zone
|
||||||
|
func (this *Inspector) validateAndReadTimeZone() error {
|
||||||
|
if this.migrationContext.TimeZone == "" {
|
||||||
|
query := `select @@global.time_zone`
|
||||||
|
if err := this.db.QueryRow(query).Scan(&this.migrationContext.TimeZone); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Infof("will use %s timezone", this.migrationContext.TimeZone)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// validateGrants verifies the user by which we're executing has necessary grants
|
// validateGrants verifies the user by which we're executing has necessary grants
|
||||||
// to do its thang.
|
// to do its thang.
|
||||||
func (this *Inspector) validateGrants() error {
|
func (this *Inspector) validateGrants() error {
|
||||||
|
@ -102,15 +102,15 @@ test_single() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo_dot
|
echo_dot
|
||||||
orig_checksum=$(gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "set session time_zone='+00:00'; select ${orig_columns} from gh_ost_test" -ss | md5sum)
|
orig_checksum=$(gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${orig_columns} from gh_ost_test" -ss | md5sum)
|
||||||
ghost_checksum=$(gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "set session time_zone='+00:00'; select ${ghost_columns} from _gh_ost_test_gho" -ss | md5sum)
|
ghost_checksum=$(gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${ghost_columns} from _gh_ost_test_gho" -ss | md5sum)
|
||||||
|
|
||||||
if [ "$orig_checksum" != "$ghost_checksum" ] ; then
|
if [ "$orig_checksum" != "$ghost_checksum" ] ; then
|
||||||
echo "ERROR $test_name: checksum mismatch"
|
echo "ERROR $test_name: checksum mismatch"
|
||||||
echo "---"
|
echo "---"
|
||||||
gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "set session time_zone='+00:00'; select ${orig_columns} from gh_ost_test" -ss
|
gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${orig_columns} from gh_ost_test" -ss
|
||||||
echo "---"
|
echo "---"
|
||||||
gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "set session time_zone='+00:00'; select ${ghost_columns} from _gh_ost_test_gho" -ss
|
gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "select ${ghost_columns} from _gh_ost_test_gho" -ss
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
--time-zone="+00:00"
|
|
12
vendor/github.com/siddontang/go-mysql/replication/row_event.go
generated
vendored
12
vendor/github.com/siddontang/go-mysql/replication/row_event.go
generated
vendored
@ -611,8 +611,10 @@ func decodeTimestamp2(data []byte, dec uint16) (interface{}, int, error) {
|
|||||||
|
|
||||||
// t := time.Unix(sec, usec*1000).UTC() // .UTC() converted by shlomi-noach
|
// t := time.Unix(sec, usec*1000).UTC() // .UTC() converted by shlomi-noach
|
||||||
// return t.Format(TimeFormat), n, nil
|
// return t.Format(TimeFormat), n, nil
|
||||||
t := time.Unix(sec, usec*1000).UTC()
|
//t := time.Unix(sec, usec*1000).UTC()
|
||||||
return t, n, nil
|
t := time.Unix(sec, usec*1000)
|
||||||
|
return t.Format(TimeFormat), n, nil
|
||||||
|
//return t, n, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
const DATETIMEF_INT_OFS int64 = 0x8000000000
|
const DATETIMEF_INT_OFS int64 = 0x8000000000
|
||||||
@ -659,11 +661,11 @@ 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))
|
||||||
|
|
||||||
t := time.Date(year, time.Month(month), day, hour, minute, second, 0, time.UTC) // added by Shlomi Noach
|
// t := time.Date(year, time.Month(month), day, hour, minute, second, 0, time.UTC) // added by Shlomi Noach
|
||||||
//return t.Format(TimeFormat), n, nil // added by Shlomi Noach
|
//return t.Format(TimeFormat), n, nil // added by Shlomi Noach
|
||||||
return t, n, nil // added by Shlomi Noach
|
// return t, n, nil // added by Shlomi Noach
|
||||||
|
|
||||||
// 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`
|
||||||
}
|
}
|
||||||
|
|
||||||
const TIMEF_OFS int64 = 0x800000000000
|
const TIMEF_OFS int64 = 0x800000000000
|
||||||
|
Loading…
Reference in New Issue
Block a user