mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved mysql parser, bug fixed for mysql grant syntax support. for issue #2338
This commit is contained in:
@@ -27,6 +27,7 @@ public class MySqlUserName extends MySqlExprImpl implements SQLName, Cloneable {
|
||||
|
||||
private String userName;
|
||||
private String host;
|
||||
private String identifiedBy;
|
||||
|
||||
private long userNameHashCod64;
|
||||
private long hashCode64;
|
||||
@@ -63,6 +64,14 @@ public class MySqlUserName extends MySqlExprImpl implements SQLName, Cloneable {
|
||||
return userName + '@' + host;
|
||||
}
|
||||
|
||||
public String getIdentifiedBy() {
|
||||
return identifiedBy;
|
||||
}
|
||||
|
||||
public void setIdentifiedBy(String identifiedBy) {
|
||||
this.identifiedBy = identifiedBy;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getSimpleName();
|
||||
}
|
||||
@@ -70,8 +79,9 @@ public class MySqlUserName extends MySqlExprImpl implements SQLName, Cloneable {
|
||||
public MySqlUserName clone() {
|
||||
MySqlUserName x = new MySqlUserName();
|
||||
|
||||
x.userName = userName;
|
||||
x.host = host;
|
||||
x.userName = userName;
|
||||
x.host = host;
|
||||
x.identifiedBy = identifiedBy;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -348,6 +348,14 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
userName.setHost(lexer.stringVal());
|
||||
}
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() == Token.IDENTIFIED) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
userName.setIdentifiedBy(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
return userName;
|
||||
}
|
||||
|
||||
@@ -696,6 +704,14 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
userName.setHost(lexer.stringVal());
|
||||
}
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() == Token.IDENTIFIED) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
userName.setIdentifiedBy(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
return userName;
|
||||
}
|
||||
return super.nameRest(name);
|
||||
|
||||
@@ -2047,10 +2047,19 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
@Override
|
||||
public boolean visit(MySqlUserName x) {
|
||||
print0(x.getUserName());
|
||||
if (x.getHost() != null) {
|
||||
|
||||
String host = x.getHost();
|
||||
if (host != null) {
|
||||
print('@');
|
||||
print0(x.getHost());
|
||||
print0(host);
|
||||
}
|
||||
|
||||
String identifiedBy = x.getIdentifiedBy();
|
||||
if (identifiedBy != null) {
|
||||
print0(ucase ? " IDENTIFIED BY " : " identified by ");
|
||||
print0(identifiedBy);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user