@@ -108,7 +108,7 @@ func (this *Applier) InitDBConnections() (err error) {
108108
109109// validateAndReadTimeZone potentially reads server time-zone
110110func (this * Applier ) validateAndReadTimeZone () error {
111- query := `select @@global.time_zone`
111+ query := `select /* gh-ost */ @@global.time_zone`
112112 if err := this .db .QueryRow (query ).Scan (& this .migrationContext .ApplierTimeZone ); err != nil {
113113 return err
114114 }
@@ -392,14 +392,15 @@ func (this *Applier) WriteChangelog(hint, value string) (string, error) {
392392 explicitId = 3
393393 }
394394 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)` ,
403404 sql .EscapeName (this .migrationContext .DatabaseName ),
404405 sql .EscapeName (this .migrationContext .GetChangelogTableName ()),
405406 )
@@ -854,7 +855,7 @@ func (this *Applier) GetSessionLockName(sessionId int64) string {
854855// ExpectUsedLock expects the special hint voluntary lock to exist on given session
855856func (this * Applier ) ExpectUsedLock (sessionId int64 ) error {
856857 var result int64
857- query := `select is_used_lock(?)`
858+ query := `select /* gh-ost */ is_used_lock(?)`
858859 lockName := this .GetSessionLockName (sessionId )
859860 this .migrationContext .Log .Infof ("Checking session lock: %s" , lockName )
860861 if err := this .db .QueryRow (query , lockName ).Scan (& result ); err != nil || result != sessionId {
@@ -867,14 +868,14 @@ func (this *Applier) ExpectUsedLock(sessionId int64) error {
867868func (this * Applier ) ExpectProcess (sessionId int64 , stateHint , infoHint string ) error {
868869 found := false
869870 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('%', ?, '%') `
878879 err := sqlutils .QueryRowsMap (this .db , query , func (m sqlutils.RowMap ) error {
879880 found = true
880881 return nil
@@ -912,10 +913,10 @@ func (this *Applier) CreateAtomicCutOverSentryTable() error {
912913 }
913914 tableName := this .migrationContext .GetOldTableName ()
914915
915- query := fmt .Sprintf (`create /* gh-ost */ table %s.%s (
916+ query := fmt .Sprintf (`
917+ create /* gh-ost */ table %s.%s (
916918 id int auto_increment primary key
917- ) engine=%s comment='%s'
918- ` ,
919+ ) engine=%s comment='%s'` ,
919920 sql .EscapeName (this .migrationContext .DatabaseName ),
920921 sql .EscapeName (tableName ),
921922 this .migrationContext .TableEngine ,
@@ -949,14 +950,14 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
949950 }()
950951
951952 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 {
953954 tableLocked <- err
954955 return err
955956 }
956957 sessionIdChan <- sessionId
957958
958959 lockResult := 0
959- query := `select get_lock(?, 0)`
960+ query := `select /* gh-ost */ get_lock(?, 0)`
960961 lockName := this .GetSessionLockName (sessionId )
961962 this .migrationContext .Log .Infof ("Grabbing voluntary lock: %s" , lockName )
962963 if err := tx .QueryRow (query , lockName ).Scan (& lockResult ); err != nil || lockResult != 1 {
@@ -967,7 +968,7 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
967968
968969 tableLockTimeoutSeconds := this .migrationContext .CutOverLockTimeoutSeconds * 2
969970 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 )
971972 if _ , err := tx .Exec (query ); err != nil {
972973 tableLocked <- err
973974 return err
@@ -1026,7 +1027,7 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
10261027 sql .EscapeName (this .migrationContext .DatabaseName ),
10271028 sql .EscapeName (this .migrationContext .GetOldTableName ()),
10281029 )
1029- query = `unlock tables`
1030+ query = `unlock /* gh-ost */ tables`
10301031 if _ , err := tx .Exec (query ); err != nil {
10311032 tableUnlocked <- err
10321033 return this .migrationContext .Log .Errore (err )
@@ -1048,13 +1049,13 @@ func (this *Applier) AtomicCutoverRename(sessionIdChan chan int64, tablesRenamed
10481049 tablesRenamed <- fmt .Errorf ("Unexpected error in AtomicCutoverRename(), injected to release blocking channel reads" )
10491050 }()
10501051 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 {
10521053 return err
10531054 }
10541055 sessionIdChan <- sessionId
10551056
10561057 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 )
10581059 if _ , err := tx .Exec (query ); err != nil {
10591060 return err
10601061 }
@@ -1080,7 +1081,7 @@ func (this *Applier) AtomicCutoverRename(sessionIdChan chan int64, tablesRenamed
10801081}
10811082
10821083func (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 )
10841085 if err := this .db .QueryRow (query ).Scan (& variableName , & result ); err != nil {
10851086 return 0 , err
10861087 }
@@ -1150,7 +1151,7 @@ func (this *Applier) ApplyDMLEventQueries(dmlEvents [](*binlog.BinlogDMLEvent))
11501151 return err
11511152 }
11521153
1153- sessionQuery := "SET SESSION time_zone = '+00:00'"
1154+ sessionQuery := "SET /* gh-ost */ SESSION time_zone = '+00:00'"
11541155 sessionQuery = fmt .Sprintf ("%s, %s" , sessionQuery , this .generateSqlModeQuery ())
11551156
11561157 if _ , err := tx .Exec (sessionQuery ); err != nil {
0 commit comments