influxql: only accept LIMIT values > 0
parent
6f3ba3efdb
commit
ddc1352073
|
@ -490,6 +490,10 @@ func (p *Parser) parseLimit() (int, error) {
|
||||||
// Parse number.
|
// Parse number.
|
||||||
n, _ := strconv.ParseInt(lit, 10, 64)
|
n, _ := strconv.ParseInt(lit, 10, 64)
|
||||||
|
|
||||||
|
if n < 1 {
|
||||||
|
return 0, &ParseError{Message: "limit must be > 0", Pos: pos}
|
||||||
|
}
|
||||||
|
|
||||||
return int(n), nil
|
return int(n), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -212,6 +212,7 @@ func TestParser_ParseStatement(t *testing.T) {
|
||||||
{s: `SELECT field1 FROM myseries GROUP`, err: `found EOF, expected BY at line 1, char 35`},
|
{s: `SELECT field1 FROM myseries GROUP`, err: `found EOF, expected BY at line 1, char 35`},
|
||||||
{s: `SELECT field1 FROM myseries LIMIT`, err: `found EOF, expected number at line 1, char 35`},
|
{s: `SELECT field1 FROM myseries LIMIT`, err: `found EOF, expected number at line 1, char 35`},
|
||||||
{s: `SELECT field1 FROM myseries LIMIT 10.5`, err: `fractional parts not allowed in limit at line 1, char 35`},
|
{s: `SELECT field1 FROM myseries LIMIT 10.5`, err: `fractional parts not allowed in limit at line 1, char 35`},
|
||||||
|
{s: `SELECT field1 FROM myseries LIMIT 0`, err: `limit must be > 0 at line 1, char 35`},
|
||||||
{s: `SELECT field1 FROM myseries ORDER`, err: `found EOF, expected BY at line 1, char 35`},
|
{s: `SELECT field1 FROM myseries ORDER`, err: `found EOF, expected BY at line 1, char 35`},
|
||||||
{s: `SELECT field1 FROM myseries ORDER BY /`, err: `found /, expected identifier, ASC, or DESC at line 1, char 38`},
|
{s: `SELECT field1 FROM myseries ORDER BY /`, err: `found /, expected identifier, ASC, or DESC at line 1, char 38`},
|
||||||
{s: `SELECT field1 FROM myseries ORDER BY 1`, err: `found 1, expected identifier, ASC, or DESC at line 1, char 38`},
|
{s: `SELECT field1 FROM myseries ORDER BY 1`, err: `found 1, expected identifier, ASC, or DESC at line 1, char 38`},
|
||||||
|
|
Loading…
Reference in New Issue