Skip to content

Commit

Permalink
Merge pull request #33 from pingcap/shenli/syntax-error
Browse files Browse the repository at this point in the history
parser: Change syntax error log
  • Loading branch information
shenli committed Sep 7, 2015
2 parents 697f3a4 + e84fca5 commit 46e8bdc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions parser/scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ func (l *lexer) next() int {
return l.c
}

func (l *lexer) err0(ln, c int, s string, args ...interface{}) {
err := errors.Errorf(fmt.Sprintf("%d:%d ", ln, c)+s, args...)
func (l *lexer) err0(ln, c int, args ...interface{}) {
err := errors.Errorf(fmt.Sprintf("line %d column %d near \"%s\"", ln, c, l.val), args...)
l.errs = append(l.errs, err)
}

func (l *lexer) err(s string, args ...interface{}) {
l.err0(l.line, l.col, s, args...)
l.err0(l.line, l.col, args...)
}

func (l *lexer) Error(s string) {
Expand Down
3 changes: 2 additions & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ func (s *session) String() string {
func (s *session) Execute(sql string) ([]rset.Recordset, error) {
stmts, err := Compile(sql)
if err != nil {
log.Errorf("Compile sql error: %s - %s", sql, err)
log.Errorf("Syntax error: %s", sql)
log.Errorf("Error occurs at %s.", err)
return nil, errors.Trace(err)
}

Expand Down

0 comments on commit 46e8bdc

Please sign in to comment.