Skip to content
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
8 changes: 7 additions & 1 deletion parser/parser_table.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package parser

import (
"errors"
"fmt"
)

Expand Down Expand Up @@ -1454,6 +1455,9 @@ func (p *Parser) parseStmt(pos Pos) (Expr, error) {
case p.matchKeyword(KeywordDesc), p.matchKeyword(KeywordDescribe):
expr, err = p.parseDescribeStmt(pos)
default:
if p.last() == nil {
return nil, errors.New("unexpected end of input")
}
return nil, fmt.Errorf("unexpected token: %q", p.last().String)
}
if err != nil {
Expand All @@ -1474,7 +1478,9 @@ func (p *Parser) parseStmt(pos Pos) (Expr, error) {
func (p *Parser) ParseStmts() ([]Expr, error) {
var stmts []Expr
for {
_ = p.lexer.consumeToken()
if err := p.lexer.consumeToken(); err != nil {
return nil, p.wrapError(err)
}
if p.lexer.isEOF() {
break
}
Expand Down
1 change: 1 addition & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func TestParser_InvalidSyntax(t *testing.T) {
// Invalid ARRAY JOIN types (only ARRAY JOIN, LEFT ARRAY JOIN, and INNER ARRAY JOIN are valid)
"SELECT * FROM t RIGHT ARRAY JOIN arr AS a", // RIGHT ARRAY JOIN not supported
"SELECT * FROM t FULL ARRAY JOIN arr AS a", // FULL ARRAY JOIN not supported
"00e1d", // invalid number that leaves lastToken nil
}
for _, sql := range invalidSQLs {
parser := NewParser(sql)
Expand Down
Loading