Merge pull request #1694 from influxdb/deleteDatabase-to-dropDatabase
Change delete to drop for [dD]ropDatabasepull/1700/head
commit
146bbd008b
|
@ -14,7 +14,7 @@ const (
|
|||
|
||||
// Database messages
|
||||
createDatabaseMessageType = messaging.MessageType(0x10)
|
||||
deleteDatabaseMessageType = messaging.MessageType(0x11)
|
||||
dropDatabaseMessageType = messaging.MessageType(0x11)
|
||||
|
||||
// Retention policy messages
|
||||
createRetentionPolicyMessageType = messaging.MessageType(0x20)
|
||||
|
@ -59,7 +59,7 @@ type createDatabaseCommand struct {
|
|||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type deleteDatabaseCommand struct {
|
||||
type dropDatabaseCommand struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
|
|
|
@ -225,7 +225,7 @@ func TestHandler_CreateDatabase_Conflict(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestHandler_DeleteDatabase(t *testing.T) {
|
||||
func TestHandler_DropDatabase(t *testing.T) {
|
||||
srvr := OpenAuthlessServer(NewMessagingClient())
|
||||
srvr.CreateDatabase("foo")
|
||||
s := NewHTTPServer(srvr)
|
||||
|
@ -239,7 +239,7 @@ func TestHandler_DeleteDatabase(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestHandler_DeleteDatabase_NotFound(t *testing.T) {
|
||||
func TestHandler_DropDatabase_NotFound(t *testing.T) {
|
||||
srvr := OpenAuthlessServer(NewMessagingClient())
|
||||
s := NewHTTPServer(srvr)
|
||||
defer s.Close()
|
||||
|
|
|
@ -204,8 +204,8 @@ func (tx *metatx) saveDatabase(db *database) error {
|
|||
return b.Put([]byte("meta"), mustMarshalJSON(db))
|
||||
}
|
||||
|
||||
// deleteDatabase removes database from the metastore.
|
||||
func (tx *metatx) deleteDatabase(name string) error {
|
||||
// dropDatabase removes database from the metastore.
|
||||
func (tx *metatx) dropDatabase(name string) error {
|
||||
return tx.Bucket([]byte("Databases")).DeleteBucket([]byte(name))
|
||||
}
|
||||
|
||||
|
|
20
server.go
20
server.go
|
@ -675,15 +675,15 @@ func (s *Server) applyCreateDatabase(m *messaging.Message) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// DeleteDatabase deletes an existing database.
|
||||
func (s *Server) DeleteDatabase(name string) error {
|
||||
c := &deleteDatabaseCommand{Name: name}
|
||||
_, err := s.broadcast(deleteDatabaseMessageType, c)
|
||||
// DropDatabase deletes an existing database.
|
||||
func (s *Server) DropDatabase(name string) error {
|
||||
c := &dropDatabaseCommand{Name: name}
|
||||
_, err := s.broadcast(dropDatabaseMessageType, c)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Server) applyDeleteDatabase(m *messaging.Message) (err error) {
|
||||
var c deleteDatabaseCommand
|
||||
func (s *Server) applyDropDatabase(m *messaging.Message) (err error) {
|
||||
var c dropDatabaseCommand
|
||||
mustUnmarshalJSON(m.Data, &c)
|
||||
|
||||
if s.databases[c.Name] == nil {
|
||||
|
@ -691,7 +691,7 @@ func (s *Server) applyDeleteDatabase(m *messaging.Message) (err error) {
|
|||
}
|
||||
|
||||
// Remove from metastore.
|
||||
err = s.meta.mustUpdate(m.Index, func(tx *metatx) error { return tx.deleteDatabase(c.Name) })
|
||||
err = s.meta.mustUpdate(m.Index, func(tx *metatx) error { return tx.dropDatabase(c.Name) })
|
||||
|
||||
// Delete the database entry.
|
||||
delete(s.databases, c.Name)
|
||||
|
@ -1846,7 +1846,7 @@ func (s *Server) executeCreateDatabaseStatement(q *influxql.CreateDatabaseStatem
|
|||
}
|
||||
|
||||
func (s *Server) executeDropDatabaseStatement(q *influxql.DropDatabaseStatement, user *User) *Result {
|
||||
return &Result{Err: s.DeleteDatabase(q.Name)}
|
||||
return &Result{Err: s.DropDatabase(q.Name)}
|
||||
}
|
||||
|
||||
func (s *Server) executeShowDatabasesStatement(q *influxql.ShowDatabasesStatement, user *User) *Result {
|
||||
|
@ -2571,8 +2571,8 @@ func (s *Server) processor(client MessagingClient, done chan struct{}) {
|
|||
err = s.applyDeleteDataNode(m)
|
||||
case createDatabaseMessageType:
|
||||
err = s.applyCreateDatabase(m)
|
||||
case deleteDatabaseMessageType:
|
||||
err = s.applyDeleteDatabase(m)
|
||||
case dropDatabaseMessageType:
|
||||
err = s.applyDropDatabase(m)
|
||||
case createUserMessageType:
|
||||
err = s.applyCreateUser(m)
|
||||
case updateUserMessageType:
|
||||
|
|
|
@ -330,7 +330,7 @@ func TestServer_DropDatabase(t *testing.T) {
|
|||
s.Restart()
|
||||
|
||||
// Drop the "foo" database and verify that it's gone.
|
||||
if err := s.DeleteDatabase("foo"); err != nil {
|
||||
if err := s.DropDatabase("foo"); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if s.DatabaseExists("foo") {
|
||||
t.Fatalf("database not actually dropped")
|
||||
|
@ -343,7 +343,7 @@ func TestServer_DropDatabase_ErrDatabaseNotFound(t *testing.T) {
|
|||
defer s.Close()
|
||||
|
||||
// Drop a database that doesn't exist.
|
||||
if err := s.DeleteDatabase("no_such_db"); err != influxdb.ErrDatabaseNotFound {
|
||||
if err := s.DropDatabase("no_such_db"); err != influxdb.ErrDatabaseNotFound {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue