From 06c909bd100ea50f35232b33b844a400fbc0c307 Mon Sep 17 00:00:00 2001 From: Shlomi Noach Date: Tue, 21 Feb 2017 17:34:49 -0700 Subject: [PATCH] Validating table name length --- go/logic/applier.go | 4 ++++ go/mysql/utils.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/go/logic/applier.go b/go/logic/applier.go index d1d7970..e84b5cf 100644 --- a/go/logic/applier.go +++ b/go/logic/applier.go @@ -142,6 +142,10 @@ func (this *Applier) ValidateOrDropExistingTables() error { return err } } + if len(this.migrationContext.GetOldTableName()) > mysql.MaxTableNameLength { + log.Fatalf("--timestamp-old-table defined, but resulting table name (%s) is too long (only %d characters allowed)", this.migrationContext.GetOldTableName(), mysql.MaxTableNameLength) + } + if this.tableExists(this.migrationContext.GetOldTableName()) { return fmt.Errorf("Table %s already exists. Panicking. Use --initially-drop-old-table to force dropping it, though I really prefer that you drop it or rename it away", sql.EscapeName(this.migrationContext.GetOldTableName())) } diff --git a/go/mysql/utils.go b/go/mysql/utils.go index c48e07e..4df7639 100644 --- a/go/mysql/utils.go +++ b/go/mysql/utils.go @@ -16,6 +16,8 @@ import ( "github.com/outbrain/golib/sqlutils" ) +const MaxTableNameLength = 64 + type ReplicationLagResult struct { Key InstanceKey Lag time.Duration