mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser for postgresql, support create table inherits
This commit is contained in:
@@ -30,12 +30,15 @@ public class SQLCreateTableStatement extends SQLStatementImpl implements SQLDDLS
|
||||
|
||||
protected List<SQLTableElement> tableElementList = new ArrayList<SQLTableElement>();
|
||||
|
||||
// for postgresql
|
||||
private SQLExprTableSource inherits;
|
||||
|
||||
public SQLCreateTableStatement(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
public SQLCreateTableStatement(String dbType){
|
||||
super (dbType);
|
||||
super(dbType);
|
||||
}
|
||||
|
||||
public SQLName getName() {
|
||||
@@ -76,7 +79,7 @@ public class SQLCreateTableStatement extends SQLStatementImpl implements SQLDDLS
|
||||
public List<SQLTableElement> getTableElementList() {
|
||||
return tableElementList;
|
||||
}
|
||||
|
||||
|
||||
public boolean isIfNotExiists() {
|
||||
return ifNotExiists;
|
||||
}
|
||||
@@ -85,26 +88,15 @@ public class SQLCreateTableStatement extends SQLStatementImpl implements SQLDDLS
|
||||
this.ifNotExiists = ifNotExiists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void output(StringBuffer buf) {
|
||||
buf.append("CREATE TABLE ");
|
||||
if (Type.GLOBAL_TEMPORARY.equals(this.type)) {
|
||||
buf.append("GLOBAL TEMPORARY ");
|
||||
} else if (Type.LOCAL_TEMPORARY.equals(this.type)) {
|
||||
buf.append("LOCAL TEMPORARY ");
|
||||
}
|
||||
public SQLExprTableSource getInherits() {
|
||||
return inherits;
|
||||
}
|
||||
|
||||
this.tableSource.output(buf);
|
||||
buf.append(" ");
|
||||
|
||||
buf.append("(");
|
||||
for (int i = 0, size = tableElementList.size(); i < size; ++i) {
|
||||
if (i != 0) {
|
||||
buf.append(", ");
|
||||
}
|
||||
tableElementList.get(i).output(buf);
|
||||
public void setInherits(SQLExprTableSource inherits) {
|
||||
if (inherits != null) {
|
||||
inherits.setParent(this);
|
||||
}
|
||||
buf.append(")");
|
||||
this.inherits = inherits;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,6 +104,7 @@ public class SQLCreateTableStatement extends SQLStatementImpl implements SQLDDLS
|
||||
if (visitor.visit(this)) {
|
||||
this.acceptChild(visitor, tableSource);
|
||||
this.acceptChild(visitor, tableElementList);
|
||||
this.acceptChild(visitor, inherits);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user