fix create table varchar binary bug and binary(10) bug

This commit is contained in:
junyu
2015-02-02 16:36:42 +08:00
parent 6622f99b8d
commit 7c7f63672f
4 changed files with 119 additions and 0 deletions
@@ -24,6 +24,7 @@ public class SQLCharacterDataType extends SQLDataTypeImpl {
private String collate;
private String charType;
private boolean hasBinary;
public final static String CHAR_TYPE_BYTE = "BYTE";
public final static String CHAR_TYPE_CHAR = "CHAR";
@@ -39,6 +40,14 @@ public class SQLCharacterDataType extends SQLDataTypeImpl {
public void setCharSetName(String charSetName) {
this.charSetName = charSetName;
}
public boolean isHasBinary() {
return hasBinary;
}
public void setHasBinary(boolean hasBinary) {
this.hasBinary = hasBinary;
}
public String getCollate() {
return collate;
@@ -376,6 +376,10 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
print(")");
}
if (x.isHasBinary()) {
print(" BINARY ");
}
if (x.getCharSetName() != null) {
print(" CHARACTER SET ");
print(x.getCharSetName());
@@ -849,6 +849,8 @@ public class SQLExprParser extends SQLParser {
case OPTIMIZE:
case GRANT:
case REVOKE:
//binary有很多含义,lexer识别了这个token,实际上应该当做普通IDENTIFIER
case BINARY:
identName = lexer.stringVal();
lexer.nextToken();
break;
@@ -1420,6 +1422,11 @@ public class SQLExprParser extends SQLParser {
}
protected SQLDataType parseCharTypeRest(SQLCharacterDataType charType) {
if (lexer.token() == Token.BINARY) {
charType.setHasBinary(true);
lexer.nextToken();
}
if (identifierEquals("CHARACTER")) {
lexer.nextToken();
@@ -1432,6 +1439,11 @@ public class SQLExprParser extends SQLParser {
lexer.nextToken();
}
if (lexer.token() == Token.BINARY) {
charType.setHasBinary(true);
lexer.nextToken();
}
if (lexer.token() == Token.IDENTIFIER) {
if (lexer.stringVal().equalsIgnoreCase("COLLATE")) {
lexer.nextToken();