mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved pg parser, fix #4146
This commit is contained in:
+20
@@ -1,6 +1,7 @@
|
||||
package com.alibaba.druid.sql.dialect.postgresql.parser;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLPartitionBy;
|
||||
import com.alibaba.druid.sql.ast.SQLPartitionByHash;
|
||||
import com.alibaba.druid.sql.ast.SQLPartitionByList;
|
||||
import com.alibaba.druid.sql.parser.*;
|
||||
|
||||
@@ -45,7 +46,26 @@ public class PGCreateTableParser extends SQLCreateTableParser {
|
||||
}
|
||||
|
||||
return list;
|
||||
} else if (lexer.identifierEquals("HASH") || lexer.identifierEquals("UNI_HASH")) {
|
||||
SQLPartitionByHash hash = new SQLPartitionByHash();
|
||||
|
||||
if (lexer.identifierEquals("UNI_HASH")) {
|
||||
hash.setUnique(true);
|
||||
}
|
||||
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() == Token.KEY) {
|
||||
lexer.nextToken();
|
||||
hash.setKey(true);
|
||||
}
|
||||
|
||||
accept(Token.LPAREN);
|
||||
this.exprParser.exprList(hash.getColumns(), hash);
|
||||
accept(Token.RPAREN);
|
||||
return hash;
|
||||
}
|
||||
|
||||
throw new ParserException("TODO " + lexer.info());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3512,6 +3512,13 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
public boolean visit(SQLCreateTableStatement x) {
|
||||
printCreateTable(x, true);
|
||||
|
||||
SQLPartitionBy partitionBy = x.getPartitioning();
|
||||
if (partitionBy != null) {
|
||||
println();
|
||||
print0(ucase ? "PARTITION BY " : "partition by ");
|
||||
partitionBy.accept(this);
|
||||
}
|
||||
|
||||
List<SQLAssignItem> options = x.getTableOptions();
|
||||
if (options.size() > 0) {
|
||||
println();
|
||||
|
||||
Reference in New Issue
Block a user