diff --git a/go/vt/dbconfigs/dbconfigs.go b/go/vt/dbconfigs/dbconfigs.go index 8434ff9a46..c44d8501e8 100644 --- a/go/vt/dbconfigs/dbconfigs.go +++ b/go/vt/dbconfigs/dbconfigs.go @@ -13,7 +13,6 @@ import ( log "github.com/golang/glog" "github.com/youtube/vitess/go/jscfg" "github.com/youtube/vitess/go/mysql" - "github.com/youtube/vitess/go/vt/key" ) // Offer a sample config - probably should load this when file isn't set. @@ -39,17 +38,16 @@ func RegisterCommonFlags() (*string, *string) { } type DBConfig struct { - Host string `json:"host"` - Port int `json:"port"` - Uname string `json:"uname"` - Pass string `json:"pass"` - Dbname string `json:"dbname"` - UnixSocket string `json:"unix_socket"` - Charset string `json:"charset"` - Memcache string `json:"memcache"` - KeyRange key.KeyRange `json:"keyrange"` - Keyspace string `json:"keyspace"` - Shard string `json:"shard"` + Host string `json:"host"` + Port int `json:"port"` + Uname string `json:"uname"` + Pass string `json:"pass"` + Dbname string `json:"dbname"` + UnixSocket string `json:"unix_socket"` + Charset string `json:"charset"` + Memcache string `json:"memcache"` + Keyspace string `json:"keyspace"` + Shard string `json:"shard"` } func (d DBConfig) String() string { diff --git a/go/vt/dbconfigs/dbconfigs_test.go b/go/vt/dbconfigs/dbconfigs_test.go deleted file mode 100644 index 069d782c3e..0000000000 --- a/go/vt/dbconfigs/dbconfigs_test.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2013, Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package dbconfigs - -import ( - "encoding/json" - "testing" -) - -func TestDbConfigLoad(t *testing.T) { - - data := "{\n" + - " \"keyrange\": {\n" + - " \"Start\": \"4000\",\n" + - " \"End\": \"8000\"\n" + - " }\n" + - "}" - - val := &DBConfig{} - if err := json.Unmarshal([]byte(data), val); err != nil { - t.Errorf("json.Unmarshal error: %v", err) - } - if string(val.KeyRange.Start.Hex()) != "4000" { - t.Errorf("Invalid Start: %v", val.KeyRange.Start.Hex()) - } - if string(val.KeyRange.End.Hex()) != "8000" { - t.Errorf("Invalid End: %v", val.KeyRange.End.Hex()) - } -} diff --git a/go/vt/tabletserver/proto/structs.go b/go/vt/tabletserver/proto/structs.go index cab216c775..39ea8c6209 100644 --- a/go/vt/tabletserver/proto/structs.go +++ b/go/vt/tabletserver/proto/structs.go @@ -6,12 +6,9 @@ package proto import ( mproto "github.com/youtube/vitess/go/mysql/proto" - "github.com/youtube/vitess/go/vt/key" ) type SessionParams struct { - DbName string - KeyRange key.KeyRange Keyspace string Shard string } diff --git a/go/vt/tabletserver/sqlquery.go b/go/vt/tabletserver/sqlquery.go index 4397b5131e..e9ef5b8553 100644 --- a/go/vt/tabletserver/sqlquery.go +++ b/go/vt/tabletserver/sqlquery.go @@ -218,20 +218,11 @@ func (sq *SqlQuery) checkState(sessionId int64, allowShutdown bool) { } func (sq *SqlQuery) GetSessionId(sessionParams *proto.SessionParams, sessionInfo *proto.SessionInfo) error { - if sessionParams.DbName == "" { - if sessionParams.Keyspace != sq.dbconfig.Keyspace { - return NewTabletError(FATAL, "Keyspace mismatch, expecting %v, received %v", sq.dbconfig.Keyspace, sessionParams.Keyspace) - } - if sessionParams.Shard != sq.dbconfig.Shard { - return NewTabletError(FATAL, "Shard mismatch, expecting %v, received %v", sq.dbconfig.Shard, sessionParams.Shard) - } - } else { - if sessionParams.DbName != sq.dbconfig.Dbname { - return NewTabletError(FATAL, "db name mismatch, expecting %v, received %v", sq.dbconfig.Dbname, sessionParams.DbName) - } - if sessionParams.KeyRange != sq.dbconfig.KeyRange { - return NewTabletError(FATAL, "KeyRange mismatch, expecting %v, received %v", sq.dbconfig.KeyRange.String(), sessionParams.KeyRange.String()) - } + if sessionParams.Keyspace != sq.dbconfig.Keyspace { + return NewTabletError(FATAL, "Keyspace mismatch, expecting %v, received %v", sq.dbconfig.Keyspace, sessionParams.Keyspace) + } + if sessionParams.Shard != sq.dbconfig.Shard { + return NewTabletError(FATAL, "Shard mismatch, expecting %v, received %v", sq.dbconfig.Shard, sessionParams.Shard) } sessionInfo.SessionId = sq.sessionId return nil diff --git a/go/vt/vttablet/agent.go b/go/vt/vttablet/agent.go index 7ce8df5f56..d2ee948997 100644 --- a/go/vt/vttablet/agent.go +++ b/go/vt/vttablet/agent.go @@ -80,7 +80,6 @@ func InitAgent( if dbcfgs.App.Dbname == "" { dbcfgs.App.Dbname = newTablet.DbName() } - dbcfgs.App.KeyRange = newTablet.KeyRange dbcfgs.App.Keyspace = newTablet.Keyspace dbcfgs.App.Shard = newTablet.Shard // Transitioning from replica to master, first disconnect @@ -90,10 +89,10 @@ func InitAgent( ts.DisallowQueries(false) } qrs := ts.LoadCustomRules() - if dbcfgs.App.KeyRange.IsPartial() { + if newTablet.KeyRange.IsPartial() { qr := ts.NewQueryRule("enforce keyspace_id range", "keyspace_id_not_in_range", ts.QR_FAIL_QUERY) qr.AddPlanCond(sqlparser.PLAN_INSERT_PK) - err = qr.AddBindVarCond("keyspace_id", true, true, ts.QR_NOTIN, dbcfgs.App.KeyRange) + err = qr.AddBindVarCond("keyspace_id", true, true, ts.QR_NOTIN, newTablet.KeyRange) if err != nil { log.Warningf("Unable to add keyspace rule: %v", err) } else {