improved sql parser for postgresql, support create table inherits

This commit is contained in:
wenshao
2014-11-30 01:35:00 +08:00
parent 1fd34a9294
commit cadce912f6
6 changed files with 102 additions and 21 deletions
@@ -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);
}