Merge pull request #3082 from influxdb/ga-cli-into

Fix CLI panic on malformed INSERT
pull/2572/merge
Gunnar 2015-06-24 11:55:27 -07:00
commit 34739f0208
3 changed files with 15 additions and 10 deletions

View File

@ -27,6 +27,7 @@
- [#3090](https://github.com/influxdb/influxdb/pull/3090): Remove database from TSDB index on DROP DATABASE.
- [#2944](https://github.com/influxdb/influxdb/issues/2944): Don't require "WHERE time" when creating continuous queries.
- [#3075](https://github.com/influxdb/influxdb/pull/3075): GROUP BY correctly when different tags have same value.
- [#3078](https://github.com/influxdb/influxdb/pull/3078): Fix CLI panic on malformed INSERT.
## v0.9.0 [2015-06-11]

View File

@ -425,16 +425,17 @@ func (c *CommandLine) parseInto(stmt string) string {
}
func (c *CommandLine) Insert(stmt string) error {
stmt = stmt[7:]
if strings.EqualFold(stmt[:4], "into") {
stmt = c.parseInto(stmt[5:])
i, point := parseNextIdentifier(stmt)
if !strings.EqualFold(i, "insert") {
fmt.Printf("ERR: found %s, expected INSERT\n", i)
return nil
}
if c.RetentionPolicy == "" {
c.RetentionPolicy = "default"
if i, r := parseNextIdentifier(point); strings.EqualFold(i, "into") {
point = c.parseInto(r)
}
_, err := c.Client.Write(client.BatchPoints{
Points: []client.Point{
client.Point{Raw: stmt},
client.Point{Raw: point},
},
Database: c.Database,
RetentionPolicy: c.RetentionPolicy,

View File

@ -106,10 +106,13 @@ func TestParseCommand_Insert(t *testing.T) {
cmd string
}{
{cmd: "INSERT cpu,host=serverA,region=us-west value=1.0"},
{cmd: " INSERT test.test cpu,host=serverA,region=us-west value=1.0"},
{cmd: "INSERT test.test cpu,host=serverA,region=us-west value=1.0"},
{cmd: "Insert test.test cpu,host=serverA,region=us-west value=1.0"},
{cmd: "insert test.test cpu,host=serverA,region=us-west value=1.0"},
{cmd: " INSERT cpu,host=serverA,region=us-west value=1.0"},
{cmd: "INSERT cpu,host=serverA,region=us-west value=1.0"},
{cmd: "insert cpu,host=serverA,region=us-west value=1.0 "},
{cmd: "insert"},
{cmd: "Insert "},
{cmd: "insert c"},
{cmd: "insert int"},
}
for _, test := range tests {