diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a31fcfac69..183a8a303e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Bugfixes - [#2084](https://github.com/influxdb/influxdb/pull/2084): Allowing leading underscores in identifiers. - [#2080](https://github.com/influxdb/influxdb/pull/2080): Graphite logs in seconds, not milliseconds. +- [#2101](https://github.com/influxdb/influxdb/pull/2101): SHOW DATABASES should name returned series "databases". ## v0.9.0-rc16 [2015-03-24] diff --git a/cmd/influxd/server_integration_test.go b/cmd/influxd/server_integration_test.go index 6a862ca4c09..61b3b37feaf 100644 --- a/cmd/influxd/server_integration_test.go +++ b/cmd/influxd/server_integration_test.go @@ -991,6 +991,11 @@ func runTestsData(t *testing.T, testName string, nodes Cluster, database, retent queryOne: true, expected: `{"results":[{}]}`, }, + { + name: "show databases", + query: `SHOW DATABASES`, + expected: `{"results":[{"series":[{"name":"databases","columns":["name"],"values":[["mydatabase"],["mydb"]]}]}]}`, + }, { name: "Check for default retention policy", query: `SHOW RETENTION POLICIES mydatabase`, @@ -1499,7 +1504,7 @@ func Test_ServerSingleGraphiteIntegration_NoDatabase(t *testing.T) { } // Need to wait for the database to be created - expected := `{"results":[{"series":[{"columns":["name"],"values":[["graphite"]]}]}]}` + expected := `{"results":[{"series":[{"name":"databases","columns":["name"],"values":[["graphite"]]}]}]}` got, ok := queryAndWait(t, nodes, "graphite", `show databases`, expected, 2*time.Second) if !ok { t.Errorf(`Test "%s" failed, expected: %s, got: %s`, testName, expected, got) diff --git a/httpd/handler_test.go b/httpd/handler_test.go index aa0e8c3a463..ba3ad147bd4 100644 --- a/httpd/handler_test.go +++ b/httpd/handler_test.go @@ -162,60 +162,6 @@ func TestHandler_ShowMeasurementsNotFound(t *testing.T) { } } -func TestHandler_Databases(t *testing.T) { - c := test.NewMessagingClient() - defer c.Close() - srvr := OpenAuthlessServer(c) - srvr.CreateDatabase("foo") - srvr.CreateDatabase("bar") - s := NewHTTPServer(srvr) - defer s.Close() - - status, body := MustHTTP("GET", s.URL+`/query`, map[string]string{"q": "SHOW DATABASES"}, nil, "") - if status != http.StatusOK { - t.Fatalf("unexpected status: %d", status) - } else if body != `{"results":[{"series":[{"columns":["name"],"values":[["bar"],["foo"]]}]}]}` { - t.Fatalf("unexpected body: %s", body) - } -} - -func TestHandler_DatabasesPrettyPrinted(t *testing.T) { - c := test.NewMessagingClient() - defer c.Close() - srvr := OpenAuthlessServer(c) - srvr.CreateDatabase("foo") - srvr.CreateDatabase("bar") - s := NewHTTPServer(srvr) - defer s.Close() - - status, body := MustHTTP("GET", s.URL+`/query`, map[string]string{"q": "SHOW DATABASES", "pretty": "true"}, nil, "") - if status != http.StatusOK { - t.Fatalf("unexpected status: %d", status) - } else if body != `{ - "results": [ - { - "series": [ - { - "columns": [ - "name" - ], - "values": [ - [ - "bar" - ], - [ - "foo" - ] - ] - } - ] - } - ] -}` { - t.Fatalf("unexpected body: %s", body) - } -} - func TestHandler_CreateDatabase(t *testing.T) { c := test.NewMessagingClient() defer c.Close() diff --git a/server.go b/server.go index 98c431d5647..60eac6034b4 100644 --- a/server.go +++ b/server.go @@ -2308,7 +2308,7 @@ func (s *Server) executeDropDatabaseStatement(q *influxql.DropDatabaseStatement, } func (s *Server) executeShowDatabasesStatement(q *influxql.ShowDatabasesStatement, user *User) *Result { - row := &influxql.Row{Columns: []string{"name"}} + row := &influxql.Row{Name: "databases", Columns: []string{"name"}} for _, name := range s.Databases() { row.Values = append(row.Values, []interface{}{name}) }