bug fixed for mysql create table parser, for issue #2999

This commit is contained in:
shaojin.wensj
2019-01-04 21:54:06 +08:00
parent 4903a9ad3a
commit 74e265aa27
3 changed files with 64 additions and 0 deletions
@@ -516,6 +516,16 @@ public class MySqlExprParser extends SQLExprParser {
column.setName(name());
column.setDataType(parseDataType());
if (lexer.identifierEquals(FnvHash.Constants.GENERATED)) {
lexer.nextToken();
acceptIdentifier("ALWAYS");
accept(Token.AS);
accept(Token.LPAREN);
SQLExpr expr = this.expr();
accept(Token.RPAREN);
column.setGeneratedAlawsAs(expr);
}
return parseColumnRest(column);
}
@@ -269,6 +269,13 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
dataType.accept(this);
}
SQLExpr generatedAlawsAs = x.getGeneratedAlawsAs();
if (generatedAlawsAs != null) {
print0(ucase ? " GENERATED ALWAYS AS (" : " generated always as (");
printExpr(generatedAlawsAs);
print(')');
}
final SQLExpr charsetExpr = x.getCharsetExpr();
if (charsetExpr != null) {
print0(ucase ? " CHARSET " : " charset ");