improved pg support, fix #4021

This commit is contained in:
高铁
2020-11-03 21:08:39 +08:00
parent bbe1bd1e75
commit 97a1adcc46
4 changed files with 46 additions and 0 deletions
@@ -37,6 +37,7 @@ public class SQLCreateIndexStatement extends SQLStatementImpl implements SQLCrea
protected List<SQLAssignItem> properties = new ArrayList<SQLAssignItem>();
protected List<SQLAssignItem> tableProperties = new ArrayList<SQLAssignItem>();
protected boolean storing;
protected boolean ifNotExists;
public SQLCreateIndexStatement() {
indexDefinition.setParent(this);
@@ -162,6 +163,7 @@ public class SQLCreateIndexStatement extends SQLStatementImpl implements SQLCrea
public SQLCreateIndexStatement clone() {
SQLCreateIndexStatement x = new SQLCreateIndexStatement();
indexDefinition.cloneTo(x.indexDefinition);
x.setIfNotExists(ifNotExists);
return x;
}
@@ -318,4 +320,12 @@ public class SQLCreateIndexStatement extends SQLStatementImpl implements SQLCrea
public List<SQLSelectOrderByItem> getColumns() {
return indexDefinition.getColumns();
}
public boolean isIfNotExists() {
return ifNotExists;
}
public void setIfNotExists(boolean ifNotExists) {
this.ifNotExists = ifNotExists;
}
}
@@ -608,6 +608,13 @@ public class PGSQLStatementParser extends SQLStatementParser {
accept(Token.INDEX);
if (lexer.token() == Token.IF) {
lexer.nextToken();
accept(Token.NOT);
accept(Token.EXISTS);
stmt.setIfNotExists(true);
}
if (lexer.identifierEquals(FnvHash.Constants.CONCURRENTLY)) {
lexer.nextToken();
stmt.setConcurrently(true);
@@ -2401,6 +2401,10 @@ public class PGOutputVisitor extends SQLASTOutputVisitor implements PGASTVisitor
print0(ucase ? "INDEX" : "index");
if (x.isIfNotExists()) {
print0(ucase ? " IF NOT EXISTS" : " if not exists");
}
if (x.isConcurrently()) {
print0(ucase ? " CONCURRENTLY" : " concurrently");
}