mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved pg support, fix #4021
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user