1.fix KEY using btree not fit mysql 5.5 syntax,2.fix ALTER TABLE COLLATE bug,3.modify parse error info,like mysql

This commit is contained in:
junyu
2014-07-10 19:03:07 +08:00
parent 4770fce08c
commit eaf2a96f15
6 changed files with 258 additions and 12 deletions
@@ -181,13 +181,39 @@ public class SQLParser {
return alias;
}
protected void printError(Token token){
String arround;
if (lexer.mark >= 0 && (lexer.text.length() > lexer.mark + 30)) {
if (lexer.mark - 5 > 0) {
arround = lexer.text.substring(lexer.mark - 5, lexer.mark + 30);
} else {
arround = lexer.text.substring(lexer.mark, lexer.mark + 30);
}
} else if (lexer.mark >= 0) {
if (lexer.mark - 5 > 0) {
arround = lexer.text.substring(lexer.mark - 5);
} else {
arround = lexer.text.substring(lexer.mark);
}
} else {
arround = lexer.text;
}
// throw new
// ParserException("syntax error, error arround:'"+arround+"',expect "
// + token + ", actual " + lexer.token() + " "
// + lexer.stringVal() + ", pos " + this.lexer.pos());
throw new ParserException("syntax error, error in :'" + arround + "',expect " + token + ", actual "
+ lexer.token() + " " + lexer.stringVal());
}
public void accept(Token token) {
if (lexer.token() == token) {
lexer.nextToken();
} else {
setErrorEndPos(lexer.pos());
throw new ParserException("syntax error, expect " + token + ", actual " + lexer.token() + " "
+ lexer.stringVal() + ", pos " + this.lexer.pos());
printError(token);
}
}
@@ -297,8 +297,10 @@ public class SQLStatementParser extends SQLParser {
continue;
}
throw new ParserException("syntax error, " + lexer.token() + " " + lexer.stringVal() + ", pos "
+ lexer.pos());
// throw new ParserException("syntax error, " + lexer.token() + " "
// + lexer.stringVal() + ", pos "
// + lexer.pos());
printError(lexer.token());
}
}