mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser.
This commit is contained in:
@@ -40,6 +40,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.expr.SQLNumberExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.parser.MySqlLexer;
|
||||
import com.alibaba.druid.util.FnvHash;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
@@ -1321,6 +1322,38 @@ public class Lexer {
|
||||
|
||||
final char first = ch;
|
||||
|
||||
if (ch == '`') {
|
||||
mark = pos;
|
||||
bufPos = 1;
|
||||
char ch;
|
||||
|
||||
int startPos = pos + 1;
|
||||
int quoteIndex = text.indexOf('`', startPos);
|
||||
if (quoteIndex == -1) {
|
||||
throw new ParserException("illegal identifier. " + info());
|
||||
}
|
||||
|
||||
hash_lower = 0xcbf29ce484222325L;
|
||||
hash = 0xcbf29ce484222325L;
|
||||
|
||||
for (int i = startPos; i < quoteIndex; ++i) {
|
||||
ch = text.charAt(i);
|
||||
|
||||
hash_lower ^= ((ch >= 'A' && ch <= 'Z') ? (ch + 32) : ch);
|
||||
hash_lower *= 0x100000001b3L;
|
||||
|
||||
hash ^= ch;
|
||||
hash *= 0x100000001b3L;
|
||||
}
|
||||
|
||||
stringVal = MySqlLexer.quoteTable.addSymbol(text, pos, quoteIndex + 1 - pos, hash);
|
||||
//stringVal = text.substring(mark, pos);
|
||||
pos = quoteIndex + 1;
|
||||
this.ch = charAt(pos);
|
||||
token = Token.IDENTIFIER;
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean firstFlag = isFirstIdentifierChar(first);
|
||||
if (!firstFlag) {
|
||||
throw new ParserException("illegal identifier. " + info());
|
||||
|
||||
Reference in New Issue
Block a user