Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHOW DATABASES returns series name "databases" #2101

Merged
merged 1 commit into from
Mar 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
7 changes: 6 additions & 1 deletion cmd/influxd/server_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down Expand Up @@ -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)
Expand Down
54 changes: 0 additions & 54 deletions httpd/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}
Expand Down