bug fixed.

This commit is contained in:
wenshao
2017-06-14 11:30:19 +08:00
parent a47342eb3b
commit 2c978ff758
4 changed files with 54 additions and 66 deletions
@@ -692,12 +692,17 @@ public class MySqlExprParser extends SQLExprParser {
if ("NAMES".equalsIgnoreCase(ident)) {
String charset = lexer.stringVal();
SQLExpr varExpr = null;
boolean chars = false;
final Token token = lexer.token();
if (lexer.token() == Token.IDENTIFIER) {
lexer.nextToken();
} else if (lexer.token() == Token.DEFAULT) {
charset = "DEFAULT";
lexer.nextToken();
} else if (lexer.token() == Token.QUES) {
varExpr = new SQLVariantRefExpr("?");
lexer.nextToken();
} else {
chars = true;
accept(Token.LITERAL_CHARS);
@@ -713,10 +718,14 @@ public class MySqlExprParser extends SQLExprParser {
item.setValue(charsetExpr);
} else {
item.setValue(chars
? new SQLCharExpr(charset)
: new SQLIdentifierExpr(charset)
);
if (varExpr != null) {
item.setValue(varExpr);
} else {
item.setValue(chars
? new SQLCharExpr(charset)
: new SQLIdentifierExpr(charset)
);
}
}
item.setTarget(var);