Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

mysql 解析出错 #1407

Closed
120003808 opened this issue Sep 5, 2016 · 6 comments
Closed

mysql 解析出错 #1407

120003808 opened this issue Sep 5, 2016 · 6 comments
Milestone

Comments

@120003808
Copy link

120003808 commented Sep 5, 2016

druidt版本1.0.25
减号语法出错,bufPos值错误
String sql = "SELECT t.id-t.id from system_conn t ";
System.out.println(sql);
SQLStatementParser parse = SQLParserUtils.createSQLStatementParser(sql, dbType);
List list = parse.parseStatementList();
SQLStatement stmt = list.get(0);
System.out.println(SQLUtils.toSQLString(stmt,dbType));
执行结果:SELECT t.id-.id
FROM system_conn t
减号后面表名t被删除了

druidt版本1.0.18不会有这个问题

@wenshao
Copy link
Member

wenshao commented Sep 11, 2016

mysql支持这样的语法哈。。

@120003808
Copy link
Author

mysql所有减法解析都会出错啊

@120003808
Copy link
Author

应该是减法是解析bufPos没有+1,直接continue了

@wenshao
Copy link
Member

wenshao commented Sep 11, 2016

是的有这个问题,问题重现了

@wenshao wenshao added this to the 1.0.26 milestone Sep 11, 2016
@120003808
Copy link
Author

MySqlLexer
if (ch == '-' && pos < text.length() - 1) {
char next_char = text.charAt(pos + 1);
if (isIdentifierChar(next_char)) {
continue;
}
}

@wenshao
Copy link
Member

wenshao commented Sep 11, 2016

问题重现并且解决,谢谢反馈

wenshao added a commit to wenshao/druid that referenced this issue Sep 11, 2016
@wenshao wenshao closed this as completed Sep 11, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants