@@ -108,7 +108,7 @@ func (this *Applier) InitDBConnections() (err error) {
108
108
109
109
// validateAndReadTimeZone potentially reads server time-zone
110
110
func (this * Applier ) validateAndReadTimeZone () error {
111
- query := `select @@global.time_zone`
111
+ query := `select /* gh-ost */ @@global.time_zone`
112
112
if err := this .db .QueryRow (query ).Scan (& this .migrationContext .ApplierTimeZone ); err != nil {
113
113
return err
114
114
}
@@ -392,14 +392,15 @@ func (this *Applier) WriteChangelog(hint, value string) (string, error) {
392
392
explicitId = 3
393
393
}
394
394
query := fmt .Sprintf (`
395
- insert /* gh-ost */ into %s.%s
396
- (id, hint, value)
397
- values
398
- (NULLIF(?, 0), ?, ?)
399
- on duplicate key update
400
- last_update=NOW(),
401
- value=VALUES(value)
402
- ` ,
395
+ insert /* gh-ost */
396
+ into
397
+ %s.%s
398
+ (id, hint, value)
399
+ values
400
+ (NULLIF(?, 0), ?, ?)
401
+ on duplicate key update
402
+ last_update=NOW(),
403
+ value=VALUES(value)` ,
403
404
sql .EscapeName (this .migrationContext .DatabaseName ),
404
405
sql .EscapeName (this .migrationContext .GetChangelogTableName ()),
405
406
)
@@ -854,7 +855,7 @@ func (this *Applier) GetSessionLockName(sessionId int64) string {
854
855
// ExpectUsedLock expects the special hint voluntary lock to exist on given session
855
856
func (this * Applier ) ExpectUsedLock (sessionId int64 ) error {
856
857
var result int64
857
- query := `select is_used_lock(?)`
858
+ query := `select /* gh-ost */ is_used_lock(?)`
858
859
lockName := this .GetSessionLockName (sessionId )
859
860
this .migrationContext .Log .Infof ("Checking session lock: %s" , lockName )
860
861
if err := this .db .QueryRow (query , lockName ).Scan (& result ); err != nil || result != sessionId {
@@ -867,14 +868,14 @@ func (this *Applier) ExpectUsedLock(sessionId int64) error {
867
868
func (this * Applier ) ExpectProcess (sessionId int64 , stateHint , infoHint string ) error {
868
869
found := false
869
870
query := `
870
- select id
871
- from information_schema.processlist
872
- where
873
- id != connection_id()
874
- and ? in (0, id )
875
- and state like concat('%', ?, '%' )
876
- and info like concat('%', ?, '%')
877
- `
871
+ select /* gh-ost */ id
872
+ from
873
+ information_schema.processlist
874
+ where
875
+ id != connection_id( )
876
+ and ? in (0, id )
877
+ and state like concat('%', ?, '%')
878
+ and info like concat('%', ?, '%') `
878
879
err := sqlutils .QueryRowsMap (this .db , query , func (m sqlutils.RowMap ) error {
879
880
found = true
880
881
return nil
@@ -912,10 +913,10 @@ func (this *Applier) CreateAtomicCutOverSentryTable() error {
912
913
}
913
914
tableName := this .migrationContext .GetOldTableName ()
914
915
915
- query := fmt .Sprintf (`create /* gh-ost */ table %s.%s (
916
+ query := fmt .Sprintf (`
917
+ create /* gh-ost */ table %s.%s (
916
918
id int auto_increment primary key
917
- ) engine=%s comment='%s'
918
- ` ,
919
+ ) engine=%s comment='%s'` ,
919
920
sql .EscapeName (this .migrationContext .DatabaseName ),
920
921
sql .EscapeName (tableName ),
921
922
this .migrationContext .TableEngine ,
@@ -949,14 +950,14 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
949
950
}()
950
951
951
952
var sessionId int64
952
- if err := tx .QueryRow (`select connection_id()` ).Scan (& sessionId ); err != nil {
953
+ if err := tx .QueryRow (`select /* gh-ost */ connection_id()` ).Scan (& sessionId ); err != nil {
953
954
tableLocked <- err
954
955
return err
955
956
}
956
957
sessionIdChan <- sessionId
957
958
958
959
lockResult := 0
959
- query := `select get_lock(?, 0)`
960
+ query := `select /* gh-ost */ get_lock(?, 0)`
960
961
lockName := this .GetSessionLockName (sessionId )
961
962
this .migrationContext .Log .Infof ("Grabbing voluntary lock: %s" , lockName )
962
963
if err := tx .QueryRow (query , lockName ).Scan (& lockResult ); err != nil || lockResult != 1 {
@@ -967,7 +968,7 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
967
968
968
969
tableLockTimeoutSeconds := this .migrationContext .CutOverLockTimeoutSeconds * 2
969
970
this .migrationContext .Log .Infof ("Setting LOCK timeout as %d seconds" , tableLockTimeoutSeconds )
970
- query = fmt .Sprintf (`set session lock_wait_timeout:=%d` , tableLockTimeoutSeconds )
971
+ query = fmt .Sprintf (`set /* gh-ost */ session lock_wait_timeout:=%d` , tableLockTimeoutSeconds )
971
972
if _ , err := tx .Exec (query ); err != nil {
972
973
tableLocked <- err
973
974
return err
@@ -1026,7 +1027,7 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
1026
1027
sql .EscapeName (this .migrationContext .DatabaseName ),
1027
1028
sql .EscapeName (this .migrationContext .GetOldTableName ()),
1028
1029
)
1029
- query = `unlock tables`
1030
+ query = `unlock /* gh-ost */ tables`
1030
1031
if _ , err := tx .Exec (query ); err != nil {
1031
1032
tableUnlocked <- err
1032
1033
return this .migrationContext .Log .Errore (err )
@@ -1048,13 +1049,13 @@ func (this *Applier) AtomicCutoverRename(sessionIdChan chan int64, tablesRenamed
1048
1049
tablesRenamed <- fmt .Errorf ("Unexpected error in AtomicCutoverRename(), injected to release blocking channel reads" )
1049
1050
}()
1050
1051
var sessionId int64
1051
- if err := tx .QueryRow (`select connection_id()` ).Scan (& sessionId ); err != nil {
1052
+ if err := tx .QueryRow (`select /* gh-ost */ connection_id()` ).Scan (& sessionId ); err != nil {
1052
1053
return err
1053
1054
}
1054
1055
sessionIdChan <- sessionId
1055
1056
1056
1057
this .migrationContext .Log .Infof ("Setting RENAME timeout as %d seconds" , this .migrationContext .CutOverLockTimeoutSeconds )
1057
- query := fmt .Sprintf (`set session lock_wait_timeout:=%d` , this .migrationContext .CutOverLockTimeoutSeconds )
1058
+ query := fmt .Sprintf (`set /* gh-ost */ session lock_wait_timeout:=%d` , this .migrationContext .CutOverLockTimeoutSeconds )
1058
1059
if _ , err := tx .Exec (query ); err != nil {
1059
1060
return err
1060
1061
}
@@ -1080,7 +1081,7 @@ func (this *Applier) AtomicCutoverRename(sessionIdChan chan int64, tablesRenamed
1080
1081
}
1081
1082
1082
1083
func (this * Applier ) ShowStatusVariable (variableName string ) (result int64 , err error ) {
1083
- query := fmt .Sprintf (`show global status like '%s'` , variableName )
1084
+ query := fmt .Sprintf (`show /* gh-ost */ global status like '%s'` , variableName )
1084
1085
if err := this .db .QueryRow (query ).Scan (& variableName , & result ); err != nil {
1085
1086
return 0 , err
1086
1087
}
@@ -1150,7 +1151,7 @@ func (this *Applier) ApplyDMLEventQueries(dmlEvents [](*binlog.BinlogDMLEvent))
1150
1151
return err
1151
1152
}
1152
1153
1153
- sessionQuery := "SET SESSION time_zone = '+00:00'"
1154
+ sessionQuery := "SET /* gh-ost */ SESSION time_zone = '+00:00'"
1154
1155
sessionQuery = fmt .Sprintf ("%s, %s" , sessionQuery , this .generateSqlModeQuery ())
1155
1156
1156
1157
if _ , err := tx .Exec (sessionQuery ); err != nil {
0 commit comments