fix build error & improve pg support

This commit is contained in:
高铁
2020-10-22 18:46:56 +08:00
parent e91ea70472
commit e71c2a6e93
6 changed files with 77 additions and 6 deletions
@@ -636,9 +636,4 @@ public class OracleCreateTableParser extends SQLCreateTableParser {
public OracleExprParser getExprParser() {
return (OracleExprParser) exprParser;
}
public SQLPartitionBy parsePartitionBy() {
return null;
}
}
@@ -0,0 +1,51 @@
package com.alibaba.druid.sql.dialect.postgresql.parser;
import com.alibaba.druid.sql.ast.SQLPartitionBy;
import com.alibaba.druid.sql.ast.SQLPartitionByList;
import com.alibaba.druid.sql.parser.*;
public class PGCreateTableParser extends SQLCreateTableParser {
public PGCreateTableParser(Lexer lexer){
super(new PGExprParser(lexer));
}
public PGCreateTableParser(String sql){
super(new PGExprParser(sql));
}
public PGCreateTableParser(SQLExprParser exprParser) {
super(exprParser);
}
public SQLPartitionBy parsePartitionBy() {
lexer.nextToken();
accept(Token.BY);
if (lexer.identifierEquals("LIST")) {
lexer.nextToken();
SQLPartitionByList list = new SQLPartitionByList();
if (lexer.token() == Token.LPAREN) {
lexer.nextToken();
list.addColumn(this.exprParser.expr());
accept(Token.RPAREN);
} else {
acceptIdentifier("COLUMNS");
accept(Token.LPAREN);
for (; ; ) {
list.addColumn(this.exprParser.name());
if (lexer.token() == Token.COMMA) {
lexer.nextToken();
continue;
}
break;
}
accept(Token.RPAREN);
}
return list;
}
throw new ParserException("TODO " + lexer.info());
}
}
@@ -673,4 +673,8 @@ public class PGSQLStatementParser extends SQLStatementParser {
return stmt;
}
public SQLCreateTableParser getSQLCreateTableParser() {
return new PGCreateTableParser(this.exprParser);
}
}
@@ -184,7 +184,7 @@ public class SQLCreateTableParser extends SQLDDLParser {
}
public SQLPartitionBy parsePartitionBy() {
throw new ParserException("TODO " + lexer.info());
return null;
}
protected SQLTableElement parseCreateTableSupplementalLogingProps() {
@@ -3343,6 +3343,9 @@ public class SQLStatementParser extends SQLParser {
} else if (lexer.identifierEquals(Constants.RESOURCE)) {
lexer.reset(markBp, markChar, Token.CREATE);
return parseCreateResourceGroup();
} else if (lexer.token() == FOREIGN) {
lexer.reset(markBp, markChar, Token.CREATE);
return parseCreateTable();
}
throw new ParserException("TODO " + lexer.info());