Fix CLI panic on malformed INSERT. Fixes #3078
parent
246ce61b85
commit
b01d63f148
|
@ -425,16 +425,17 @@ func (c *CommandLine) parseInto(stmt string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CommandLine) Insert(stmt string) error {
|
func (c *CommandLine) Insert(stmt string) error {
|
||||||
stmt = stmt[7:]
|
i, point := parseNextIdentifier(stmt)
|
||||||
if strings.EqualFold(stmt[:4], "into") {
|
if !strings.EqualFold(i, "insert") {
|
||||||
stmt = c.parseInto(stmt[5:])
|
fmt.Println("ERR: missing space after INSERT")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
if c.RetentionPolicy == "" {
|
if i, r := parseNextIdentifier(point); strings.EqualFold(i, "into") {
|
||||||
c.RetentionPolicy = "default"
|
point = c.parseInto(r)
|
||||||
}
|
}
|
||||||
_, err := c.Client.Write(client.BatchPoints{
|
_, err := c.Client.Write(client.BatchPoints{
|
||||||
Points: []client.Point{
|
Points: []client.Point{
|
||||||
client.Point{Raw: stmt},
|
client.Point{Raw: point},
|
||||||
},
|
},
|
||||||
Database: c.Database,
|
Database: c.Database,
|
||||||
RetentionPolicy: c.RetentionPolicy,
|
RetentionPolicy: c.RetentionPolicy,
|
||||||
|
|
Loading…
Reference in New Issue