From 88fcf759c4506455dedba2388d5a9c6d299b4998 Mon Sep 17 00:00:00 2001 From: Timothy Raymond Date: Tue, 14 Jul 2015 18:10:01 -0400 Subject: [PATCH 1/2] Allow semicolons to trail database names in "use" Prior to this commit, the "use" command treated trailing semicolons as significant parts of the database name. This lead to a confusing user experience since other parts of influxql treat the trailing semicolon as a statement separator, or appear to ignore it. A typical use case looks something like: > show databases; -- snip -- > use foo; This commit trims off trailing semicolons from database names in "use" commands if present to match user expectations. Fixes #2258 --- cmd/influx/main.go | 2 +- cmd/influx/main_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/influx/main.go b/cmd/influx/main.go index a7f4b42b906..1df7f67afce 100644 --- a/cmd/influx/main.go +++ b/cmd/influx/main.go @@ -321,7 +321,7 @@ func (c *CommandLine) SetAuth(cmd string) { } func (c *CommandLine) use(cmd string) { - args := strings.Split(strings.TrimSpace(cmd), " ") + args := strings.Split(strings.TrimSuffix(strings.TrimSpace(cmd), ";"), " ") if len(args) != 2 { fmt.Printf("Could not parse database name from %q.\n", cmd) return diff --git a/cmd/influx/main_test.go b/cmd/influx/main_test.go index 3c42b3a5de5..97c2682ff5f 100644 --- a/cmd/influx/main_test.go +++ b/cmd/influx/main_test.go @@ -75,6 +75,7 @@ func TestParseCommand_Use(t *testing.T) { {cmd: "use db"}, {cmd: " use db"}, {cmd: "use db "}, + {cmd: "use db;"}, {cmd: "Use db"}, } @@ -82,6 +83,10 @@ func TestParseCommand_Use(t *testing.T) { if !c.ParseCommand(test.cmd) { t.Fatalf(`Command "use" failed for %q.`, test.cmd) } + + if c.Database != "db" { + t.Fatalf(`Command "use" changed database to %q. Expected db`, c.Database) + } } } From bdfec0e222d034962e0e53a84a800186d255cec5 Mon Sep 17 00:00:00 2001 From: Timothy Raymond Date: Thu, 16 Jul 2015 21:45:17 -0400 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index da714a21917..d61298f6376 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - [#3304](https://github.com/influxdb/influxdb/pull/3304): Fixed httpd logger to log user from query params. Thanks @jhorwit2 - [#3332](https://github.com/influxdb/influxdb/pull/3332): Add SLIMIT and SOFFSET to string version of AST. - [#3335](https://github.com/influxdb/influxdb/pull/3335): Don't drop all data on DROP DATABASE. Thanks to @PierreF for the report +- [#3356](https://github.com/influxdb/influxdb/pull/3356): Disregard semicolons after database name in use command. Thanks @timraymond. ## v0.9.1 [2015-07-02]