mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
fix build error & improve pg support
This commit is contained in:
@@ -636,9 +636,4 @@ public class OracleCreateTableParser extends SQLCreateTableParser {
|
||||
public OracleExprParser getExprParser() {
|
||||
return (OracleExprParser) exprParser;
|
||||
}
|
||||
|
||||
|
||||
public SQLPartitionBy parsePartitionBy() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+51
@@ -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());
|
||||
}
|
||||
}
|
||||
+4
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user