renaming to gh-ost
This commit is contained in:
parent
92d09dbcf6
commit
9d055dbda7
@ -1,2 +1,2 @@
|
|||||||
# gh-osc
|
# gh-ost
|
||||||
GitHub's Online Schema Change for MySQL
|
GitHub's Online Schema Change for MySQL
|
||||||
|
12
build.sh
12
build.sh
@ -2,19 +2,19 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
buildpath=/tmp/gh-osc
|
buildpath=/tmp/gh-ost
|
||||||
target=gh-osc
|
target=gh-ost
|
||||||
timestamp=$(date "+%Y%m%d%H%M%S")
|
timestamp=$(date "+%Y%m%d%H%M%S")
|
||||||
mkdir -p ${buildpath}
|
mkdir -p ${buildpath}
|
||||||
gobuild="go build -o $buildpath/$target go/cmd/gh-osc/main.go"
|
gobuild="go build -o $buildpath/$target go/cmd/gh-ost/main.go"
|
||||||
|
|
||||||
echo "Building OS/X binary"
|
echo "Building OS/X binary"
|
||||||
echo "GO15VENDOREXPERIMENT=1 GOOS=darwin GOARCH=amd64 $gobuild" | bash
|
echo "GO15VENDOREXPERIMENT=1 GOOS=darwin GOARCH=amd64 $gobuild" | bash
|
||||||
(cd $buildpath && tar cfz ./gh-osc-binary-osx-${timestamp}.tar.gz $target)
|
(cd $buildpath && tar cfz ./gh-ost-binary-osx-${timestamp}.tar.gz $target)
|
||||||
|
|
||||||
echo "Building linux binary"
|
echo "Building linux binary"
|
||||||
echo "GO15VENDOREXPERIMENT=1 GOOS=linux GOARCH=amd64 $gobuild" | bash
|
echo "GO15VENDOREXPERIMENT=1 GOOS=linux GOARCH=amd64 $gobuild" | bash
|
||||||
(cd $buildpath && tar cfz ./gh-osc-binary-linux-${timestamp}.tar.gz $target)
|
(cd $buildpath && tar cfz ./gh-ost-binary-linux-${timestamp}.tar.gz $target)
|
||||||
|
|
||||||
echo "Binaries found in:"
|
echo "Binaries found in:"
|
||||||
ls -1 $buildpath/gh-osc-binary*${timestamp}.tar.gz
|
ls -1 $buildpath/gh-ost-binary*${timestamp}.tar.gz
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package base
|
package base
|
||||||
@ -13,8 +13,8 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/github/gh-osc/go/mysql"
|
"github.com/github/gh-ost/go/mysql"
|
||||||
"github.com/github/gh-osc/go/sql"
|
"github.com/github/gh-ost/go/sql"
|
||||||
|
|
||||||
"gopkg.in/gcfg.v1"
|
"gopkg.in/gcfg.v1"
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package base
|
package base
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package binlog
|
package binlog
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/github/gh-osc/go/sql"
|
"github.com/github/gh-ost/go/sql"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package binlog
|
package binlog
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/github/gh-osc/go/mysql"
|
"github.com/github/gh-ost/go/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BinlogEntry describes an entry in the binary log
|
// BinlogEntry describes an entry in the binary log
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package binlog
|
package binlog
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package binlog
|
package binlog
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package binlog
|
package binlog
|
||||||
@ -8,8 +8,8 @@ package binlog
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/github/gh-osc/go/mysql"
|
"github.com/github/gh-ost/go/mysql"
|
||||||
"github.com/github/gh-osc/go/sql"
|
"github.com/github/gh-ost/go/sql"
|
||||||
|
|
||||||
"github.com/outbrain/golib/log"
|
"github.com/outbrain/golib/log"
|
||||||
gomysql "github.com/siddontang/go-mysql/mysql"
|
gomysql "github.com/siddontang/go-mysql/mysql"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package binlog
|
package binlog
|
||||||
@ -14,7 +14,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
// "strings"
|
// "strings"
|
||||||
|
|
||||||
"github.com/github/gh-osc/go/os"
|
"github.com/github/gh-ost/go/os"
|
||||||
"github.com/outbrain/golib/log"
|
"github.com/outbrain/golib/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package binlog
|
package binlog
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
@ -10,8 +10,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/github/gh-osc/go/base"
|
"github.com/github/gh-ost/go/base"
|
||||||
"github.com/github/gh-osc/go/logic"
|
"github.com/github/gh-ost/go/logic"
|
||||||
"github.com/outbrain/golib/log"
|
"github.com/outbrain/golib/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ func main() {
|
|||||||
flag.BoolVar(&migrationContext.AllowedRunningOnMaster, "allow-on-master", false, "allow this migration to run directly on master. Preferably it would run on a replica")
|
flag.BoolVar(&migrationContext.AllowedRunningOnMaster, "allow-on-master", false, "allow this migration to run directly on master. Preferably it would run on a replica")
|
||||||
|
|
||||||
executeFlag := flag.Bool("execute", false, "actually execute the alter & migrate the table. Default is noop: do some tests and exit")
|
executeFlag := flag.Bool("execute", false, "actually execute the alter & migrate the table. Default is noop: do some tests and exit")
|
||||||
flag.BoolVar(&migrationContext.TestOnReplica, "test-on-replica", false, "Have the migration run on a replica, not on the master. At the end of migration tables are not swapped; gh-osc issues `STOP SLAVE` and you can compare the two tables for building trust")
|
flag.BoolVar(&migrationContext.TestOnReplica, "test-on-replica", false, "Have the migration run on a replica, not on the master. At the end of migration tables are not swapped; gh-ost issues `STOP SLAVE` and you can compare the two tables for building trust")
|
||||||
flag.BoolVar(&migrationContext.OkToDropTable, "ok-to-drop-table", false, "Shall the tool drop the old table at end of operation. DROPping tables can be a long locking operation, which is why I'm not doing it by default. I'm an online tool, yes?")
|
flag.BoolVar(&migrationContext.OkToDropTable, "ok-to-drop-table", false, "Shall the tool drop the old table at end of operation. DROPping tables can be a long locking operation, which is why I'm not doing it by default. I'm an online tool, yes?")
|
||||||
flag.BoolVar(&migrationContext.QuickAndBumpySwapTables, "quick-and-bumpy-swap-tables", false, "Shall the tool issue a faster swapping of tables at end of operation, at the cost of causing a brief period of time when the table does not exist? This will cause queries on table to fail with error (as opposed to being locked for a longer duration of a swap)")
|
flag.BoolVar(&migrationContext.QuickAndBumpySwapTables, "quick-and-bumpy-swap-tables", false, "Shall the tool issue a faster swapping of tables at end of operation, at the cost of causing a brief period of time when the table does not exist? This will cause queries on table to fail with error (as opposed to being locked for a longer duration of a swap)")
|
||||||
flag.BoolVar(&migrationContext.InitiallyDropOldTable, "initially-drop-old-table", false, "Drop a possibly existing OLD table (remains from a previous run?) before beginning operation. Default is to panic and abort if such table exists")
|
flag.BoolVar(&migrationContext.InitiallyDropOldTable, "initially-drop-old-table", false, "Drop a possibly existing OLD table (remains from a previous run?) before beginning operation. Default is to panic and abort if such table exists")
|
||||||
@ -47,10 +47,10 @@ func main() {
|
|||||||
migrationContext.ChunkSize = 100000
|
migrationContext.ChunkSize = 100000
|
||||||
}
|
}
|
||||||
flag.Int64Var(&migrationContext.MaxLagMillisecondsThrottleThreshold, "max-lag-millis", 1500, "replication lag at which to throttle operation")
|
flag.Int64Var(&migrationContext.MaxLagMillisecondsThrottleThreshold, "max-lag-millis", 1500, "replication lag at which to throttle operation")
|
||||||
flag.StringVar(&migrationContext.ReplictionLagQuery, "replication-lag-query", "", "Query that detects replication lag in seconds. Result can be a floating point (by default gh-osc issues SHOW SLAVE STATUS and reads Seconds_behind_master). If you're using pt-heartbeat, query would be something like: SELECT ROUND(UNIX_TIMESTAMP() - MAX(UNIX_TIMESTAMP(ts))) AS delay FROM my_schema.heartbeat")
|
flag.StringVar(&migrationContext.ReplictionLagQuery, "replication-lag-query", "", "Query that detects replication lag in seconds. Result can be a floating point (by default gh-ost issues SHOW SLAVE STATUS and reads Seconds_behind_master). If you're using pt-heartbeat, query would be something like: SELECT ROUND(UNIX_TIMESTAMP() - MAX(UNIX_TIMESTAMP(ts))) AS delay FROM my_schema.heartbeat")
|
||||||
throttleControlReplicas := flag.String("throttle-control-replicas", "", "List of replicas on which to check for lag; comma delimited. Example: myhost1.com:3306,myhost2.com,myhost3.com:3307")
|
throttleControlReplicas := flag.String("throttle-control-replicas", "", "List of replicas on which to check for lag; comma delimited. Example: myhost1.com:3306,myhost2.com,myhost3.com:3307")
|
||||||
flag.StringVar(&migrationContext.ThrottleFlagFile, "throttle-flag-file", "", "operation pauses when this file exists; hint: use a file that is specific to the table being altered")
|
flag.StringVar(&migrationContext.ThrottleFlagFile, "throttle-flag-file", "", "operation pauses when this file exists; hint: use a file that is specific to the table being altered")
|
||||||
flag.StringVar(&migrationContext.ThrottleAdditionalFlagFile, "throttle-additional-flag-file", "/tmp/gh-osc.throttle", "operation pauses when this file exists; hint: keep default, use for throttling multiple gh-osc operations")
|
flag.StringVar(&migrationContext.ThrottleAdditionalFlagFile, "throttle-additional-flag-file", "/tmp/gh-ost.throttle", "operation pauses when this file exists; hint: keep default, use for throttling multiple gh-ost operations")
|
||||||
maxLoad := flag.String("max-load", "", "Comma delimited status-name=threshold. e.g: 'Threads_running=100,Threads_connected=500'")
|
maxLoad := flag.String("max-load", "", "Comma delimited status-name=threshold. e.g: 'Threads_running=100,Threads_connected=500'")
|
||||||
quiet := flag.Bool("quiet", false, "quiet")
|
quiet := flag.Bool("quiet", false, "quiet")
|
||||||
verbose := flag.Bool("verbose", false, "verbose")
|
verbose := flag.Bool("verbose", false, "verbose")
|
||||||
@ -60,7 +60,7 @@ func main() {
|
|||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *help {
|
if *help {
|
||||||
fmt.Fprintf(os.Stderr, "Usage of gh-osc:\n")
|
fmt.Fprintf(os.Stderr, "Usage of gh-ost:\n")
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ func main() {
|
|||||||
log.Fatale(err)
|
log.Fatale(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("starting gh-osc")
|
log.Info("starting gh-ost")
|
||||||
|
|
||||||
migrator := logic.NewMigrator()
|
migrator := logic.NewMigrator()
|
||||||
err := migrator.Migrate()
|
err := migrator.Migrate()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package logic
|
package logic
|
||||||
@ -11,10 +11,10 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/github/gh-osc/go/base"
|
"github.com/github/gh-ost/go/base"
|
||||||
"github.com/github/gh-osc/go/binlog"
|
"github.com/github/gh-ost/go/binlog"
|
||||||
"github.com/github/gh-osc/go/mysql"
|
"github.com/github/gh-ost/go/mysql"
|
||||||
"github.com/github/gh-osc/go/sql"
|
"github.com/github/gh-ost/go/sql"
|
||||||
|
|
||||||
"github.com/outbrain/golib/log"
|
"github.com/outbrain/golib/log"
|
||||||
"github.com/outbrain/golib/sqlutils"
|
"github.com/outbrain/golib/sqlutils"
|
||||||
@ -70,7 +70,7 @@ func (this *Applier) validateConnection(db *gosql.DB) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *Applier) tableExists(tableName string) (tableFound bool) {
|
func (this *Applier) tableExists(tableName string) (tableFound bool) {
|
||||||
query := fmt.Sprintf(`show /* gh-osc */ table status from %s like '%s'`, sql.EscapeName(this.migrationContext.DatabaseName), tableName)
|
query := fmt.Sprintf(`show /* gh-ost */ table status from %s like '%s'`, sql.EscapeName(this.migrationContext.DatabaseName), tableName)
|
||||||
|
|
||||||
sqlutils.QueryRowsMap(this.db, query, func(m sqlutils.RowMap) error {
|
sqlutils.QueryRowsMap(this.db, query, func(m sqlutils.RowMap) error {
|
||||||
tableFound = true
|
tableFound = true
|
||||||
@ -102,7 +102,7 @@ func (this *Applier) ValidateOrDropExistingTables() error {
|
|||||||
|
|
||||||
// CreateGhostTable creates the ghost table on the applier host
|
// CreateGhostTable creates the ghost table on the applier host
|
||||||
func (this *Applier) CreateGhostTable() error {
|
func (this *Applier) CreateGhostTable() error {
|
||||||
query := fmt.Sprintf(`create /* gh-osc */ table %s.%s like %s.%s`,
|
query := fmt.Sprintf(`create /* gh-ost */ table %s.%s like %s.%s`,
|
||||||
sql.EscapeName(this.migrationContext.DatabaseName),
|
sql.EscapeName(this.migrationContext.DatabaseName),
|
||||||
sql.EscapeName(this.migrationContext.GetGhostTableName()),
|
sql.EscapeName(this.migrationContext.GetGhostTableName()),
|
||||||
sql.EscapeName(this.migrationContext.DatabaseName),
|
sql.EscapeName(this.migrationContext.DatabaseName),
|
||||||
@ -121,7 +121,7 @@ func (this *Applier) CreateGhostTable() error {
|
|||||||
|
|
||||||
// AlterGhost applies `alter` statement on ghost table
|
// AlterGhost applies `alter` statement on ghost table
|
||||||
func (this *Applier) AlterGhost() error {
|
func (this *Applier) AlterGhost() error {
|
||||||
query := fmt.Sprintf(`alter /* gh-osc */ table %s.%s %s`,
|
query := fmt.Sprintf(`alter /* gh-ost */ table %s.%s %s`,
|
||||||
sql.EscapeName(this.migrationContext.DatabaseName),
|
sql.EscapeName(this.migrationContext.DatabaseName),
|
||||||
sql.EscapeName(this.migrationContext.GetGhostTableName()),
|
sql.EscapeName(this.migrationContext.GetGhostTableName()),
|
||||||
this.migrationContext.AlterStatement,
|
this.migrationContext.AlterStatement,
|
||||||
@ -143,7 +143,7 @@ func (this *Applier) CreateChangelogTable() error {
|
|||||||
if err := this.DropChangelogTable(); err != nil {
|
if err := this.DropChangelogTable(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
query := fmt.Sprintf(`create /* gh-osc */ table %s.%s (
|
query := fmt.Sprintf(`create /* gh-ost */ table %s.%s (
|
||||||
id bigint auto_increment,
|
id bigint auto_increment,
|
||||||
last_update timestamp not null DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
last_update timestamp not null DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
hint varchar(64) charset ascii not null,
|
hint varchar(64) charset ascii not null,
|
||||||
@ -168,7 +168,7 @@ func (this *Applier) CreateChangelogTable() error {
|
|||||||
|
|
||||||
// dropTable drops a given table on the applied host
|
// dropTable drops a given table on the applied host
|
||||||
func (this *Applier) dropTable(tableName string) error {
|
func (this *Applier) dropTable(tableName string) error {
|
||||||
query := fmt.Sprintf(`drop /* gh-osc */ table if exists %s.%s`,
|
query := fmt.Sprintf(`drop /* gh-ost */ table if exists %s.%s`,
|
||||||
sql.EscapeName(this.migrationContext.DatabaseName),
|
sql.EscapeName(this.migrationContext.DatabaseName),
|
||||||
sql.EscapeName(tableName),
|
sql.EscapeName(tableName),
|
||||||
)
|
)
|
||||||
@ -211,7 +211,7 @@ func (this *Applier) WriteChangelog(hint, value string) (string, error) {
|
|||||||
explicitId = 3
|
explicitId = 3
|
||||||
}
|
}
|
||||||
query := fmt.Sprintf(`
|
query := fmt.Sprintf(`
|
||||||
insert /* gh-osc */ into %s.%s
|
insert /* gh-ost */ into %s.%s
|
||||||
(id, hint, value)
|
(id, hint, value)
|
||||||
values
|
values
|
||||||
(NULLIF(?, 0), ?, ?)
|
(NULLIF(?, 0), ?, ?)
|
||||||
@ -336,7 +336,7 @@ func (this *Applier) __unused_IterationIsComplete() (bool, error) {
|
|||||||
}
|
}
|
||||||
args = append(args, explodedArgs...)
|
args = append(args, explodedArgs...)
|
||||||
query := fmt.Sprintf(`
|
query := fmt.Sprintf(`
|
||||||
select /* gh-osc IterationIsComplete */ 1
|
select /* gh-ost IterationIsComplete */ 1
|
||||||
from %s.%s
|
from %s.%s
|
||||||
where (%s) and (%s)
|
where (%s) and (%s)
|
||||||
limit 1
|
limit 1
|
||||||
@ -434,7 +434,7 @@ func (this *Applier) ApplyIterationInsertQuery() (chunkSize int64, rowsAffected
|
|||||||
|
|
||||||
// LockTables
|
// LockTables
|
||||||
func (this *Applier) LockTables() error {
|
func (this *Applier) LockTables() error {
|
||||||
// query := fmt.Sprintf(`lock /* gh-osc */ tables %s.%s write, %s.%s write, %s.%s write`,
|
// query := fmt.Sprintf(`lock /* gh-ost */ tables %s.%s write, %s.%s write, %s.%s write`,
|
||||||
// sql.EscapeName(this.migrationContext.DatabaseName),
|
// sql.EscapeName(this.migrationContext.DatabaseName),
|
||||||
// sql.EscapeName(this.migrationContext.OriginalTableName),
|
// sql.EscapeName(this.migrationContext.OriginalTableName),
|
||||||
// sql.EscapeName(this.migrationContext.DatabaseName),
|
// sql.EscapeName(this.migrationContext.DatabaseName),
|
||||||
@ -442,7 +442,7 @@ func (this *Applier) LockTables() error {
|
|||||||
// sql.EscapeName(this.migrationContext.DatabaseName),
|
// sql.EscapeName(this.migrationContext.DatabaseName),
|
||||||
// sql.EscapeName(this.migrationContext.GetChangelogTableName()),
|
// sql.EscapeName(this.migrationContext.GetChangelogTableName()),
|
||||||
// )
|
// )
|
||||||
query := fmt.Sprintf(`lock /* gh-osc */ tables %s.%s write`,
|
query := fmt.Sprintf(`lock /* gh-ost */ tables %s.%s write`,
|
||||||
sql.EscapeName(this.migrationContext.DatabaseName),
|
sql.EscapeName(this.migrationContext.DatabaseName),
|
||||||
sql.EscapeName(this.migrationContext.OriginalTableName),
|
sql.EscapeName(this.migrationContext.OriginalTableName),
|
||||||
)
|
)
|
||||||
@ -457,7 +457,7 @@ func (this *Applier) LockTables() error {
|
|||||||
|
|
||||||
// UnlockTables
|
// UnlockTables
|
||||||
func (this *Applier) UnlockTables() error {
|
func (this *Applier) UnlockTables() error {
|
||||||
query := `unlock /* gh-osc */ tables`
|
query := `unlock /* gh-ost */ tables`
|
||||||
log.Infof("Unlocking tables")
|
log.Infof("Unlocking tables")
|
||||||
if _, err := sqlutils.ExecNoPrepare(this.singletonDB, query); err != nil {
|
if _, err := sqlutils.ExecNoPrepare(this.singletonDB, query); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -468,7 +468,7 @@ func (this *Applier) UnlockTables() error {
|
|||||||
|
|
||||||
// SwapTablesQuickAndBumpy
|
// SwapTablesQuickAndBumpy
|
||||||
func (this *Applier) SwapTablesQuickAndBumpy() error {
|
func (this *Applier) SwapTablesQuickAndBumpy() error {
|
||||||
query := fmt.Sprintf(`alter /* gh-osc */ table %s.%s rename %s`,
|
query := fmt.Sprintf(`alter /* gh-ost */ table %s.%s rename %s`,
|
||||||
sql.EscapeName(this.migrationContext.DatabaseName),
|
sql.EscapeName(this.migrationContext.DatabaseName),
|
||||||
sql.EscapeName(this.migrationContext.OriginalTableName),
|
sql.EscapeName(this.migrationContext.OriginalTableName),
|
||||||
sql.EscapeName(this.migrationContext.GetOldTableName()),
|
sql.EscapeName(this.migrationContext.GetOldTableName()),
|
||||||
@ -478,7 +478,7 @@ func (this *Applier) SwapTablesQuickAndBumpy() error {
|
|||||||
if _, err := sqlutils.ExecNoPrepare(this.singletonDB, query); err != nil {
|
if _, err := sqlutils.ExecNoPrepare(this.singletonDB, query); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
query = fmt.Sprintf(`alter /* gh-osc */ table %s.%s rename %s`,
|
query = fmt.Sprintf(`alter /* gh-ost */ table %s.%s rename %s`,
|
||||||
sql.EscapeName(this.migrationContext.DatabaseName),
|
sql.EscapeName(this.migrationContext.DatabaseName),
|
||||||
sql.EscapeName(this.migrationContext.GetGhostTableName()),
|
sql.EscapeName(this.migrationContext.GetGhostTableName()),
|
||||||
sql.EscapeName(this.migrationContext.OriginalTableName),
|
sql.EscapeName(this.migrationContext.OriginalTableName),
|
||||||
@ -513,7 +513,7 @@ func (this *Applier) SwapTablesAtomic(sessionIdChan chan int64) error {
|
|||||||
}
|
}
|
||||||
sessionIdChan <- sessionId
|
sessionIdChan <- sessionId
|
||||||
|
|
||||||
query = fmt.Sprintf(`rename /* gh-osc */ table %s.%s to %s.%s, %s.%s to %s.%s`,
|
query = fmt.Sprintf(`rename /* gh-ost */ table %s.%s to %s.%s, %s.%s to %s.%s`,
|
||||||
sql.EscapeName(this.migrationContext.DatabaseName),
|
sql.EscapeName(this.migrationContext.DatabaseName),
|
||||||
sql.EscapeName(this.migrationContext.OriginalTableName),
|
sql.EscapeName(this.migrationContext.OriginalTableName),
|
||||||
sql.EscapeName(this.migrationContext.DatabaseName),
|
sql.EscapeName(this.migrationContext.DatabaseName),
|
||||||
@ -539,7 +539,7 @@ func (this *Applier) SwapTablesAtomic(sessionIdChan chan int64) error {
|
|||||||
// We need to keep the SQL thread active so as to complete processing received events,
|
// We need to keep the SQL thread active so as to complete processing received events,
|
||||||
// and have them written to the binary log, so that we can then read them via streamer
|
// and have them written to the binary log, so that we can then read them via streamer
|
||||||
func (this *Applier) StopSlaveIOThread() error {
|
func (this *Applier) StopSlaveIOThread() error {
|
||||||
query := `stop /* gh-osc */ slave io_thread`
|
query := `stop /* gh-ost */ slave io_thread`
|
||||||
log.Infof("Stopping replication")
|
log.Infof("Stopping replication")
|
||||||
if _, err := sqlutils.ExecNoPrepare(this.db, query); err != nil {
|
if _, err := sqlutils.ExecNoPrepare(this.db, query); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -646,7 +646,7 @@ func (this *Applier) IssueBlockingQueryOnVoluntaryLock(sessionIdChan chan int64)
|
|||||||
|
|
||||||
// Grab
|
// Grab
|
||||||
query := fmt.Sprintf(`
|
query := fmt.Sprintf(`
|
||||||
select /* gh-osc blocking-query-%s */
|
select /* gh-ost blocking-query-%s */
|
||||||
release_lock(?)
|
release_lock(?)
|
||||||
from %s.%s
|
from %s.%s
|
||||||
where
|
where
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package logic
|
package logic
|
||||||
@ -10,9 +10,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/github/gh-osc/go/base"
|
"github.com/github/gh-ost/go/base"
|
||||||
"github.com/github/gh-osc/go/mysql"
|
"github.com/github/gh-ost/go/mysql"
|
||||||
"github.com/github/gh-osc/go/sql"
|
"github.com/github/gh-ost/go/sql"
|
||||||
|
|
||||||
"github.com/outbrain/golib/log"
|
"github.com/outbrain/golib/log"
|
||||||
"github.com/outbrain/golib/sqlutils"
|
"github.com/outbrain/golib/sqlutils"
|
||||||
@ -142,7 +142,7 @@ func (this *Inspector) validateConnection() error {
|
|||||||
// 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 {
|
||||||
query := `show /* gh-osc */ grants for current_user()`
|
query := `show /* gh-ost */ grants for current_user()`
|
||||||
foundAll := false
|
foundAll := false
|
||||||
foundSuper := false
|
foundSuper := false
|
||||||
foundReplicationSlave := false
|
foundReplicationSlave := false
|
||||||
@ -242,7 +242,7 @@ func (this *Inspector) validateBinlogs() error {
|
|||||||
if !this.migrationContext.SwitchToRowBinlogFormat {
|
if !this.migrationContext.SwitchToRowBinlogFormat {
|
||||||
return fmt.Errorf("You must be using ROW binlog format. I can switch it for you, provided --switch-to-rbr and that %s:%d doesn't have replicas", this.connectionConfig.Key.Hostname, this.connectionConfig.Key.Port)
|
return fmt.Errorf("You must be using ROW binlog format. I can switch it for you, provided --switch-to-rbr and that %s:%d doesn't have replicas", this.connectionConfig.Key.Hostname, this.connectionConfig.Key.Port)
|
||||||
}
|
}
|
||||||
query := fmt.Sprintf(`show /* gh-osc */ slave hosts`)
|
query := fmt.Sprintf(`show /* gh-ost */ slave hosts`)
|
||||||
countReplicas := 0
|
countReplicas := 0
|
||||||
err := sqlutils.QueryRowsMap(this.db, query, func(rowMap sqlutils.RowMap) error {
|
err := sqlutils.QueryRowsMap(this.db, query, func(rowMap sqlutils.RowMap) error {
|
||||||
countReplicas++
|
countReplicas++
|
||||||
@ -268,7 +268,7 @@ func (this *Inspector) validateBinlogs() error {
|
|||||||
|
|
||||||
// validateTable makes sure the table we need to operate on actually exists
|
// validateTable makes sure the table we need to operate on actually exists
|
||||||
func (this *Inspector) validateTable() error {
|
func (this *Inspector) validateTable() error {
|
||||||
query := fmt.Sprintf(`show /* gh-osc */ table status from %s like '%s'`, sql.EscapeName(this.migrationContext.DatabaseName), this.migrationContext.OriginalTableName)
|
query := fmt.Sprintf(`show /* gh-ost */ table status from %s like '%s'`, sql.EscapeName(this.migrationContext.DatabaseName), this.migrationContext.OriginalTableName)
|
||||||
|
|
||||||
tableFound := false
|
tableFound := false
|
||||||
err := sqlutils.QueryRowsMap(this.db, query, func(rowMap sqlutils.RowMap) error {
|
err := sqlutils.QueryRowsMap(this.db, query, func(rowMap sqlutils.RowMap) error {
|
||||||
@ -325,7 +325,7 @@ func (this *Inspector) validateTableForeignKeys() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *Inspector) estimateTableRowsViaExplain() error {
|
func (this *Inspector) estimateTableRowsViaExplain() error {
|
||||||
query := fmt.Sprintf(`explain select /* gh-osc */ * from %s.%s where 1=1`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))
|
query := fmt.Sprintf(`explain select /* gh-ost */ * from %s.%s where 1=1`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))
|
||||||
|
|
||||||
outputFound := false
|
outputFound := false
|
||||||
err := sqlutils.QueryRowsMap(this.db, query, func(rowMap sqlutils.RowMap) error {
|
err := sqlutils.QueryRowsMap(this.db, query, func(rowMap sqlutils.RowMap) error {
|
||||||
@ -347,7 +347,7 @@ func (this *Inspector) estimateTableRowsViaExplain() error {
|
|||||||
|
|
||||||
func (this *Inspector) countTableRows() error {
|
func (this *Inspector) countTableRows() error {
|
||||||
log.Infof("As instructed, I'm issuing a SELECT COUNT(*) on the table. This may take a while")
|
log.Infof("As instructed, I'm issuing a SELECT COUNT(*) on the table. This may take a while")
|
||||||
query := fmt.Sprintf(`select /* gh-osc */ count(*) as rows from %s.%s`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))
|
query := fmt.Sprintf(`select /* gh-ost */ count(*) as rows from %s.%s`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))
|
||||||
if err := this.db.QueryRow(query).Scan(&this.migrationContext.RowsEstimate); err != nil {
|
if err := this.db.QueryRow(query).Scan(&this.migrationContext.RowsEstimate); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package logic
|
package logic
|
||||||
@ -13,10 +13,10 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/github/gh-osc/go/base"
|
"github.com/github/gh-ost/go/base"
|
||||||
"github.com/github/gh-osc/go/binlog"
|
"github.com/github/gh-ost/go/binlog"
|
||||||
"github.com/github/gh-osc/go/mysql"
|
"github.com/github/gh-ost/go/mysql"
|
||||||
"github.com/github/gh-osc/go/sql"
|
"github.com/github/gh-ost/go/sql"
|
||||||
|
|
||||||
"github.com/outbrain/golib/log"
|
"github.com/outbrain/golib/log"
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package logic
|
package logic
|
||||||
@ -11,9 +11,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/github/gh-osc/go/base"
|
"github.com/github/gh-ost/go/base"
|
||||||
"github.com/github/gh-osc/go/binlog"
|
"github.com/github/gh-ost/go/binlog"
|
||||||
"github.com/github/gh-osc/go/mysql"
|
"github.com/github/gh-ost/go/mysql"
|
||||||
|
|
||||||
"github.com/outbrain/golib/log"
|
"github.com/outbrain/golib/log"
|
||||||
"github.com/outbrain/golib/sqlutils"
|
"github.com/outbrain/golib/sqlutils"
|
||||||
@ -137,7 +137,7 @@ func (this *EventsStreamer) validateConnection() error {
|
|||||||
// 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 *EventsStreamer) readCurrentBinlogCoordinates() error {
|
func (this *EventsStreamer) readCurrentBinlogCoordinates() error {
|
||||||
query := `show /* gh-osc readCurrentBinlogCoordinates */ master status`
|
query := `show /* gh-ost readCurrentBinlogCoordinates */ master status`
|
||||||
foundMasterStatus := false
|
foundMasterStatus := false
|
||||||
err := sqlutils.QueryRowsMap(this.db, query, func(m sqlutils.RowMap) error {
|
err := sqlutils.QueryRowsMap(this.db, query, func(m sqlutils.RowMap) error {
|
||||||
this.nextBinlogCoordinates = &mysql.BinlogCoordinates{
|
this.nextBinlogCoordinates = &mysql.BinlogCoordinates{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2015 Shlomi Noach, courtesy Booking.com
|
Copyright 2015 Shlomi Noach, courtesy Booking.com
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mysql
|
package mysql
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mysql
|
package mysql
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2015 Shlomi Noach, courtesy Booking.com
|
Copyright 2015 Shlomi Noach, courtesy Booking.com
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mysql
|
package mysql
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2015 Shlomi Noach, courtesy Booking.com
|
Copyright 2015 Shlomi Noach, courtesy Booking.com
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mysql
|
package mysql
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mysql
|
package mysql
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
|
|
||||||
func execCmd(commandText string, arguments ...string) (*exec.Cmd, string, error) {
|
func execCmd(commandText string, arguments ...string) (*exec.Cmd, string, error) {
|
||||||
commandBytes := []byte(commandText)
|
commandBytes := []byte(commandText)
|
||||||
tmpFile, err := ioutil.TempFile("", "gh-osc-process-cmd-")
|
tmpFile, err := ioutil.TempFile("", "gh-ost-process-cmd-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", log.Errore(err)
|
return nil, "", log.Errore(err)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
@ -188,7 +188,7 @@ func BuildRangeInsertQuery(databaseName, originalTableName, ghostTableName strin
|
|||||||
transactionalClause = "lock in share mode"
|
transactionalClause = "lock in share mode"
|
||||||
}
|
}
|
||||||
result = fmt.Sprintf(`
|
result = fmt.Sprintf(`
|
||||||
insert /* gh-osc %s.%s */ ignore into %s.%s (%s)
|
insert /* gh-ost %s.%s */ ignore into %s.%s (%s)
|
||||||
(select %s from %s.%s force index (%s)
|
(select %s from %s.%s force index (%s)
|
||||||
where (%s and %s) %s
|
where (%s and %s) %s
|
||||||
)
|
)
|
||||||
@ -231,7 +231,7 @@ func BuildUniqueKeyRangeEndPreparedQuery(databaseName, tableName string, uniqueK
|
|||||||
uniqueKeyColumnDescending[i] = fmt.Sprintf("%s desc", uniqueKeyColumns[i])
|
uniqueKeyColumnDescending[i] = fmt.Sprintf("%s desc", uniqueKeyColumns[i])
|
||||||
}
|
}
|
||||||
result = fmt.Sprintf(`
|
result = fmt.Sprintf(`
|
||||||
select /* gh-osc %s.%s %s */ %s
|
select /* gh-ost %s.%s %s */ %s
|
||||||
from (
|
from (
|
||||||
select
|
select
|
||||||
%s
|
%s
|
||||||
@ -276,7 +276,7 @@ func buildUniqueKeyMinMaxValuesPreparedQuery(databaseName, tableName string, uni
|
|||||||
uniqueKeyColumnOrder[i] = fmt.Sprintf("%s %s", uniqueKeyColumns[i], order)
|
uniqueKeyColumnOrder[i] = fmt.Sprintf("%s %s", uniqueKeyColumns[i], order)
|
||||||
}
|
}
|
||||||
query := fmt.Sprintf(`
|
query := fmt.Sprintf(`
|
||||||
select /* gh-osc %s.%s */ %s
|
select /* gh-ost %s.%s */ %s
|
||||||
from
|
from
|
||||||
%s.%s
|
%s.%s
|
||||||
order by
|
order by
|
||||||
@ -307,7 +307,7 @@ func BuildDMLDeleteQuery(databaseName, tableName string, tableColumns, uniqueKey
|
|||||||
return result, uniqueKeyArgs, err
|
return result, uniqueKeyArgs, err
|
||||||
}
|
}
|
||||||
result = fmt.Sprintf(`
|
result = fmt.Sprintf(`
|
||||||
delete /* gh-osc %s.%s */
|
delete /* gh-ost %s.%s */
|
||||||
from
|
from
|
||||||
%s.%s
|
%s.%s
|
||||||
where
|
where
|
||||||
@ -344,7 +344,7 @@ func BuildDMLInsertQuery(databaseName, tableName string, tableColumns, sharedCol
|
|||||||
preparedValues := buildPreparedValues(sharedColumns.Len())
|
preparedValues := buildPreparedValues(sharedColumns.Len())
|
||||||
|
|
||||||
result = fmt.Sprintf(`
|
result = fmt.Sprintf(`
|
||||||
replace /* gh-osc %s.%s */ into
|
replace /* gh-ost %s.%s */ into
|
||||||
%s.%s
|
%s.%s
|
||||||
(%s)
|
(%s)
|
||||||
values
|
values
|
||||||
@ -397,7 +397,7 @@ func BuildDMLUpdateQuery(databaseName, tableName string, tableColumns, sharedCol
|
|||||||
|
|
||||||
equalsComparison, err := BuildEqualsPreparedComparison(uniqueKeyColumns.Names)
|
equalsComparison, err := BuildEqualsPreparedComparison(uniqueKeyColumns.Names)
|
||||||
result = fmt.Sprintf(`
|
result = fmt.Sprintf(`
|
||||||
update /* gh-osc %s.%s */
|
update /* gh-ost %s.%s */
|
||||||
%s.%s
|
%s.%s
|
||||||
set
|
set
|
||||||
%s
|
%s
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
@ -175,7 +175,7 @@ func TestBuildRangeInsertQuery(t *testing.T) {
|
|||||||
query, explodedArgs, err := BuildRangeInsertQuery(databaseName, originalTableName, ghostTableName, sharedColumns, uniqueKey, uniqueKeyColumns, rangeStartValues, rangeEndValues, rangeStartArgs, rangeEndArgs, true, false)
|
query, explodedArgs, err := BuildRangeInsertQuery(databaseName, originalTableName, ghostTableName, sharedColumns, uniqueKey, uniqueKeyColumns, rangeStartValues, rangeEndValues, rangeStartArgs, rangeEndArgs, true, false)
|
||||||
test.S(t).ExpectNil(err)
|
test.S(t).ExpectNil(err)
|
||||||
expected := `
|
expected := `
|
||||||
insert /* gh-osc mydb.tbl */ ignore into mydb.ghost (id, name, position)
|
insert /* gh-ost mydb.tbl */ ignore into mydb.ghost (id, name, position)
|
||||||
(select id, name, position from mydb.tbl force index (PRIMARY)
|
(select id, name, position from mydb.tbl force index (PRIMARY)
|
||||||
where (((id > @v1s) or ((id = @v1s))) and ((id < @v1e) or ((id = @v1e))))
|
where (((id > @v1s) or ((id = @v1s))) and ((id < @v1e) or ((id = @v1e))))
|
||||||
)
|
)
|
||||||
@ -194,7 +194,7 @@ func TestBuildRangeInsertQuery(t *testing.T) {
|
|||||||
query, explodedArgs, err := BuildRangeInsertQuery(databaseName, originalTableName, ghostTableName, sharedColumns, uniqueKey, uniqueKeyColumns, rangeStartValues, rangeEndValues, rangeStartArgs, rangeEndArgs, true, false)
|
query, explodedArgs, err := BuildRangeInsertQuery(databaseName, originalTableName, ghostTableName, sharedColumns, uniqueKey, uniqueKeyColumns, rangeStartValues, rangeEndValues, rangeStartArgs, rangeEndArgs, true, false)
|
||||||
test.S(t).ExpectNil(err)
|
test.S(t).ExpectNil(err)
|
||||||
expected := `
|
expected := `
|
||||||
insert /* gh-osc mydb.tbl */ ignore into mydb.ghost (id, name, position)
|
insert /* gh-ost mydb.tbl */ ignore into mydb.ghost (id, name, position)
|
||||||
(select id, name, position from mydb.tbl force index (name_position_uidx)
|
(select id, name, position from mydb.tbl force index (name_position_uidx)
|
||||||
where (((name > @v1s) or (((name = @v1s)) AND (position > @v2s)) or ((name = @v1s) and (position = @v2s))) and ((name < @v1e) or (((name = @v1e)) AND (position < @v2e)) or ((name = @v1e) and (position = @v2e))))
|
where (((name > @v1s) or (((name = @v1s)) AND (position > @v2s)) or ((name = @v1s) and (position = @v2s))) and ((name < @v1e) or (((name = @v1e)) AND (position < @v2e)) or ((name = @v1e) and (position = @v2e))))
|
||||||
)
|
)
|
||||||
@ -218,7 +218,7 @@ func TestBuildRangeInsertPreparedQuery(t *testing.T) {
|
|||||||
query, explodedArgs, err := BuildRangeInsertPreparedQuery(databaseName, originalTableName, ghostTableName, sharedColumns, uniqueKey, uniqueKeyColumns, rangeStartArgs, rangeEndArgs, true, true)
|
query, explodedArgs, err := BuildRangeInsertPreparedQuery(databaseName, originalTableName, ghostTableName, sharedColumns, uniqueKey, uniqueKeyColumns, rangeStartArgs, rangeEndArgs, true, true)
|
||||||
test.S(t).ExpectNil(err)
|
test.S(t).ExpectNil(err)
|
||||||
expected := `
|
expected := `
|
||||||
insert /* gh-osc mydb.tbl */ ignore into mydb.ghost (id, name, position)
|
insert /* gh-ost mydb.tbl */ ignore into mydb.ghost (id, name, position)
|
||||||
(select id, name, position from mydb.tbl force index (name_position_uidx)
|
(select id, name, position from mydb.tbl force index (name_position_uidx)
|
||||||
where (((name > ?) or (((name = ?)) AND (position > ?)) or ((name = ?) and (position = ?))) and ((name < ?) or (((name = ?)) AND (position < ?)) or ((name = ?) and (position = ?))))
|
where (((name > ?) or (((name = ?)) AND (position > ?)) or ((name = ?) and (position = ?))) and ((name < ?) or (((name = ?)) AND (position < ?)) or ((name = ?) and (position = ?))))
|
||||||
lock in share mode )
|
lock in share mode )
|
||||||
@ -240,7 +240,7 @@ func TestBuildUniqueKeyRangeEndPreparedQuery(t *testing.T) {
|
|||||||
query, explodedArgs, err := BuildUniqueKeyRangeEndPreparedQuery(databaseName, originalTableName, uniqueKeyColumns, rangeStartArgs, rangeEndArgs, chunkSize, "test")
|
query, explodedArgs, err := BuildUniqueKeyRangeEndPreparedQuery(databaseName, originalTableName, uniqueKeyColumns, rangeStartArgs, rangeEndArgs, chunkSize, "test")
|
||||||
test.S(t).ExpectNil(err)
|
test.S(t).ExpectNil(err)
|
||||||
expected := `
|
expected := `
|
||||||
select /* gh-osc mydb.tbl test */ name, position
|
select /* gh-ost mydb.tbl test */ name, position
|
||||||
from (
|
from (
|
||||||
select
|
select
|
||||||
name, position
|
name, position
|
||||||
@ -268,7 +268,7 @@ func TestBuildUniqueKeyMinValuesPreparedQuery(t *testing.T) {
|
|||||||
query, err := BuildUniqueKeyMinValuesPreparedQuery(databaseName, originalTableName, uniqueKeyColumns)
|
query, err := BuildUniqueKeyMinValuesPreparedQuery(databaseName, originalTableName, uniqueKeyColumns)
|
||||||
test.S(t).ExpectNil(err)
|
test.S(t).ExpectNil(err)
|
||||||
expected := `
|
expected := `
|
||||||
select /* gh-osc mydb.tbl */ name, position
|
select /* gh-ost mydb.tbl */ name, position
|
||||||
from
|
from
|
||||||
mydb.tbl
|
mydb.tbl
|
||||||
order by
|
order by
|
||||||
@ -281,7 +281,7 @@ func TestBuildUniqueKeyMinValuesPreparedQuery(t *testing.T) {
|
|||||||
query, err := BuildUniqueKeyMaxValuesPreparedQuery(databaseName, originalTableName, uniqueKeyColumns)
|
query, err := BuildUniqueKeyMaxValuesPreparedQuery(databaseName, originalTableName, uniqueKeyColumns)
|
||||||
test.S(t).ExpectNil(err)
|
test.S(t).ExpectNil(err)
|
||||||
expected := `
|
expected := `
|
||||||
select /* gh-osc mydb.tbl */ name, position
|
select /* gh-ost mydb.tbl */ name, position
|
||||||
from
|
from
|
||||||
mydb.tbl
|
mydb.tbl
|
||||||
order by
|
order by
|
||||||
@ -303,7 +303,7 @@ func TestBuildDMLDeleteQuery(t *testing.T) {
|
|||||||
query, uniqueKeyArgs, err := BuildDMLDeleteQuery(databaseName, tableName, tableColumns, uniqueKeyColumns, args)
|
query, uniqueKeyArgs, err := BuildDMLDeleteQuery(databaseName, tableName, tableColumns, uniqueKeyColumns, args)
|
||||||
test.S(t).ExpectNil(err)
|
test.S(t).ExpectNil(err)
|
||||||
expected := `
|
expected := `
|
||||||
delete /* gh-osc mydb.tbl */
|
delete /* gh-ost mydb.tbl */
|
||||||
from
|
from
|
||||||
mydb.tbl
|
mydb.tbl
|
||||||
where
|
where
|
||||||
@ -318,7 +318,7 @@ func TestBuildDMLDeleteQuery(t *testing.T) {
|
|||||||
query, uniqueKeyArgs, err := BuildDMLDeleteQuery(databaseName, tableName, tableColumns, uniqueKeyColumns, args)
|
query, uniqueKeyArgs, err := BuildDMLDeleteQuery(databaseName, tableName, tableColumns, uniqueKeyColumns, args)
|
||||||
test.S(t).ExpectNil(err)
|
test.S(t).ExpectNil(err)
|
||||||
expected := `
|
expected := `
|
||||||
delete /* gh-osc mydb.tbl */
|
delete /* gh-ost mydb.tbl */
|
||||||
from
|
from
|
||||||
mydb.tbl
|
mydb.tbl
|
||||||
where
|
where
|
||||||
@ -333,7 +333,7 @@ func TestBuildDMLDeleteQuery(t *testing.T) {
|
|||||||
query, uniqueKeyArgs, err := BuildDMLDeleteQuery(databaseName, tableName, tableColumns, uniqueKeyColumns, args)
|
query, uniqueKeyArgs, err := BuildDMLDeleteQuery(databaseName, tableName, tableColumns, uniqueKeyColumns, args)
|
||||||
test.S(t).ExpectNil(err)
|
test.S(t).ExpectNil(err)
|
||||||
expected := `
|
expected := `
|
||||||
delete /* gh-osc mydb.tbl */
|
delete /* gh-ost mydb.tbl */
|
||||||
from
|
from
|
||||||
mydb.tbl
|
mydb.tbl
|
||||||
where
|
where
|
||||||
@ -361,7 +361,7 @@ func TestBuildDMLInsertQuery(t *testing.T) {
|
|||||||
query, sharedArgs, err := BuildDMLInsertQuery(databaseName, tableName, tableColumns, sharedColumns, args)
|
query, sharedArgs, err := BuildDMLInsertQuery(databaseName, tableName, tableColumns, sharedColumns, args)
|
||||||
test.S(t).ExpectNil(err)
|
test.S(t).ExpectNil(err)
|
||||||
expected := `
|
expected := `
|
||||||
replace /* gh-osc mydb.tbl */
|
replace /* gh-ost mydb.tbl */
|
||||||
into mydb.tbl
|
into mydb.tbl
|
||||||
(id, name, position, age)
|
(id, name, position, age)
|
||||||
values
|
values
|
||||||
@ -375,7 +375,7 @@ func TestBuildDMLInsertQuery(t *testing.T) {
|
|||||||
query, sharedArgs, err := BuildDMLInsertQuery(databaseName, tableName, tableColumns, sharedColumns, args)
|
query, sharedArgs, err := BuildDMLInsertQuery(databaseName, tableName, tableColumns, sharedColumns, args)
|
||||||
test.S(t).ExpectNil(err)
|
test.S(t).ExpectNil(err)
|
||||||
expected := `
|
expected := `
|
||||||
replace /* gh-osc mydb.tbl */
|
replace /* gh-ost mydb.tbl */
|
||||||
into mydb.tbl
|
into mydb.tbl
|
||||||
(position, name, age, id)
|
(position, name, age, id)
|
||||||
values
|
values
|
||||||
@ -408,7 +408,7 @@ func TestBuildDMLUpdateQuery(t *testing.T) {
|
|||||||
query, sharedArgs, uniqueKeyArgs, err := BuildDMLUpdateQuery(databaseName, tableName, tableColumns, sharedColumns, uniqueKeyColumns, valueArgs, whereArgs)
|
query, sharedArgs, uniqueKeyArgs, err := BuildDMLUpdateQuery(databaseName, tableName, tableColumns, sharedColumns, uniqueKeyColumns, valueArgs, whereArgs)
|
||||||
test.S(t).ExpectNil(err)
|
test.S(t).ExpectNil(err)
|
||||||
expected := `
|
expected := `
|
||||||
update /* gh-osc mydb.tbl */
|
update /* gh-ost mydb.tbl */
|
||||||
mydb.tbl
|
mydb.tbl
|
||||||
set id=?, name=?, position=?, age=?
|
set id=?, name=?, position=?, age=?
|
||||||
where
|
where
|
||||||
@ -424,7 +424,7 @@ func TestBuildDMLUpdateQuery(t *testing.T) {
|
|||||||
query, sharedArgs, uniqueKeyArgs, err := BuildDMLUpdateQuery(databaseName, tableName, tableColumns, sharedColumns, uniqueKeyColumns, valueArgs, whereArgs)
|
query, sharedArgs, uniqueKeyArgs, err := BuildDMLUpdateQuery(databaseName, tableName, tableColumns, sharedColumns, uniqueKeyColumns, valueArgs, whereArgs)
|
||||||
test.S(t).ExpectNil(err)
|
test.S(t).ExpectNil(err)
|
||||||
expected := `
|
expected := `
|
||||||
update /* gh-osc mydb.tbl */
|
update /* gh-ost mydb.tbl */
|
||||||
mydb.tbl
|
mydb.tbl
|
||||||
set id=?, name=?, position=?, age=?
|
set id=?, name=?, position=?, age=?
|
||||||
where
|
where
|
||||||
@ -440,7 +440,7 @@ func TestBuildDMLUpdateQuery(t *testing.T) {
|
|||||||
query, sharedArgs, uniqueKeyArgs, err := BuildDMLUpdateQuery(databaseName, tableName, tableColumns, sharedColumns, uniqueKeyColumns, valueArgs, whereArgs)
|
query, sharedArgs, uniqueKeyArgs, err := BuildDMLUpdateQuery(databaseName, tableName, tableColumns, sharedColumns, uniqueKeyColumns, valueArgs, whereArgs)
|
||||||
test.S(t).ExpectNil(err)
|
test.S(t).ExpectNil(err)
|
||||||
expected := `
|
expected := `
|
||||||
update /* gh-osc mydb.tbl */
|
update /* gh-ost mydb.tbl */
|
||||||
mydb.tbl
|
mydb.tbl
|
||||||
set id=?, name=?, position=?, age=?
|
set id=?, name=?, position=?, age=?
|
||||||
where
|
where
|
||||||
@ -456,7 +456,7 @@ func TestBuildDMLUpdateQuery(t *testing.T) {
|
|||||||
query, sharedArgs, uniqueKeyArgs, err := BuildDMLUpdateQuery(databaseName, tableName, tableColumns, sharedColumns, uniqueKeyColumns, valueArgs, whereArgs)
|
query, sharedArgs, uniqueKeyArgs, err := BuildDMLUpdateQuery(databaseName, tableName, tableColumns, sharedColumns, uniqueKeyColumns, valueArgs, whereArgs)
|
||||||
test.S(t).ExpectNil(err)
|
test.S(t).ExpectNil(err)
|
||||||
expected := `
|
expected := `
|
||||||
update /* gh-osc mydb.tbl */
|
update /* gh-ost mydb.tbl */
|
||||||
mydb.tbl
|
mydb.tbl
|
||||||
set id=?, name=?, position=?, age=?
|
set id=?, name=?, position=?, age=?
|
||||||
where
|
where
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 GitHub Inc.
|
Copyright 2016 GitHub Inc.
|
||||||
See https://github.com/github/gh-osc/blob/master/LICENSE
|
See https://github.com/github/gh-ost/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
Loading…
Reference in New Issue
Block a user