forked from alibaba/druid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request alibaba#4913 from chenhaoyus/master
Add oscar parser support
- Loading branch information
Showing
29 changed files
with
5,690 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/com/alibaba/druid/sql/dialect/oscar/ast/OscarObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 1999-2017 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.druid.sql.dialect.oscar.ast; | ||
|
||
import com.alibaba.druid.sql.ast.SQLObject; | ||
import com.alibaba.druid.sql.dialect.oscar.visitor.OscarASTVisitor; | ||
|
||
public interface OscarObject extends SQLObject { | ||
void accept0(OscarASTVisitor visitor); | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/alibaba/druid/sql/dialect/oscar/ast/OscarObjectImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 1999-2017 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.druid.sql.dialect.oscar.ast; | ||
|
||
import com.alibaba.druid.sql.ast.SQLObjectImpl; | ||
import com.alibaba.druid.sql.dialect.oscar.visitor.OscarASTVisitor; | ||
import com.alibaba.druid.sql.visitor.SQLASTVisitor; | ||
|
||
public abstract class OscarObjectImpl extends SQLObjectImpl implements OscarObject { | ||
public OscarObjectImpl() { | ||
} | ||
|
||
@Override | ||
protected void accept0(SQLASTVisitor visitor) { | ||
this.accept0((OscarASTVisitor) visitor); | ||
} | ||
|
||
public abstract void accept0(OscarASTVisitor visitor); | ||
} |
78 changes: 78 additions & 0 deletions
78
src/main/java/com/alibaba/druid/sql/dialect/oscar/ast/OscarTop.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright 1999-2017 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.druid.sql.dialect.oscar.ast; | ||
|
||
import com.alibaba.druid.sql.ast.SQLExpr; | ||
import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr; | ||
import com.alibaba.druid.sql.dialect.oscar.visitor.OscarASTVisitor; | ||
|
||
public class OscarTop extends OscarObjectImpl { | ||
private SQLExpr expr; | ||
private boolean percent; | ||
private boolean withTies; | ||
|
||
public OscarTop() { | ||
} | ||
|
||
@Override | ||
public void accept0(OscarASTVisitor visitor) { | ||
} | ||
|
||
public OscarTop(SQLExpr expr) { | ||
this.setExpr(expr); | ||
} | ||
|
||
public SQLExpr getExpr() { | ||
return expr; | ||
} | ||
|
||
public void setExpr(SQLExpr expr) { | ||
if (expr != null) { | ||
expr.setParent(this); | ||
} | ||
this.expr = expr; | ||
} | ||
|
||
public void setExpr(int expr) { | ||
this.setExpr(new SQLIntegerExpr(expr)); | ||
} | ||
|
||
public boolean isPercent() { | ||
return percent; | ||
} | ||
|
||
public void setPercent(boolean percent) { | ||
this.percent = percent; | ||
} | ||
|
||
public boolean isWithTies() { | ||
return withTies; | ||
} | ||
|
||
public void setWithTies(boolean withTies) { | ||
this.withTies = withTies; | ||
} | ||
|
||
public OscarTop clone() { | ||
OscarTop x = new OscarTop(); | ||
if (expr != null) { | ||
x.setExpr(expr.clone()); | ||
} | ||
x.percent = percent; | ||
x.withTies = withTies; | ||
return x; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/alibaba/druid/sql/dialect/oscar/ast/expr/OscarExpr.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 1999-2017 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.druid.sql.dialect.oscar.ast.expr; | ||
|
||
import com.alibaba.druid.sql.ast.SQLExpr; | ||
import com.alibaba.druid.sql.dialect.oscar.ast.OscarObject; | ||
|
||
public interface OscarExpr extends SQLExpr, OscarObject { | ||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/com/alibaba/druid/sql/dialect/oscar/ast/stmt/OscarAlterSchemaStatement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 1999-2017 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.druid.sql.dialect.oscar.ast.stmt; | ||
|
||
import com.alibaba.druid.sql.ast.SQLStatementImpl; | ||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr; | ||
import com.alibaba.druid.sql.ast.statement.SQLAlterStatement; | ||
import com.alibaba.druid.sql.dialect.oscar.visitor.OscarASTVisitor; | ||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitor; | ||
import com.alibaba.druid.sql.visitor.SQLASTVisitor; | ||
|
||
public class OscarAlterSchemaStatement extends SQLStatementImpl implements OscarStatement, SQLAlterStatement { | ||
private SQLIdentifierExpr schemaName; | ||
private SQLIdentifierExpr newName; | ||
private SQLIdentifierExpr newOwner; | ||
|
||
public SQLIdentifierExpr getSchemaName() { | ||
return schemaName; | ||
} | ||
|
||
public void setSchemaName(SQLIdentifierExpr schemaName) { | ||
this.schemaName = schemaName; | ||
} | ||
|
||
protected void accept0(SQLASTVisitor visitor) { | ||
accept0((PGASTVisitor) visitor); | ||
} | ||
|
||
public SQLIdentifierExpr getNewName() { | ||
return newName; | ||
} | ||
|
||
public void setNewName(SQLIdentifierExpr newName) { | ||
this.newName = newName; | ||
} | ||
|
||
public SQLIdentifierExpr getNewOwner() { | ||
return newOwner; | ||
} | ||
|
||
public void setNewOwner(SQLIdentifierExpr newOwner) { | ||
this.newOwner = newOwner; | ||
} | ||
|
||
@Override | ||
public void accept0(OscarASTVisitor visitor) { | ||
if (visitor.visit(this)) { | ||
acceptChild(visitor, this.schemaName); | ||
acceptChild(visitor, this.newName); | ||
acceptChild(visitor, this.newOwner); | ||
} | ||
visitor.endVisit(this); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...va/com/alibaba/druid/sql/dialect/oscar/ast/stmt/OscarAlterTableAlterColumnSetNotNull.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright 1999-2017 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.druid.sql.dialect.oscar.ast.stmt; | ||
|
||
public class OscarAlterTableAlterColumnSetNotNull { | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/alibaba/druid/sql/dialect/oscar/ast/stmt/OscarConnectToStatement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.alibaba.druid.sql.dialect.oscar.ast.stmt; | ||
|
||
import com.alibaba.druid.DbType; | ||
import com.alibaba.druid.sql.ast.SQLName; | ||
import com.alibaba.druid.sql.ast.SQLStatementImpl; | ||
import com.alibaba.druid.sql.dialect.oscar.visitor.OscarASTVisitor; | ||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitor; | ||
import com.alibaba.druid.sql.visitor.SQLASTVisitor; | ||
|
||
public class OscarConnectToStatement extends SQLStatementImpl implements OscarStatement { | ||
private SQLName target; | ||
|
||
public OscarConnectToStatement() { | ||
super(DbType.oscar); | ||
} | ||
|
||
protected void accept0(SQLASTVisitor visitor) { | ||
this.accept0((PGASTVisitor) visitor); | ||
} | ||
|
||
@Override | ||
public void accept0(OscarASTVisitor v) { | ||
if (v.visit(this)) { | ||
acceptChild(v, target); | ||
} | ||
v.endVisit(this); | ||
} | ||
|
||
public SQLName getTarget() { | ||
return target; | ||
} | ||
|
||
public void setTarget(SQLName x) { | ||
if (x != null) { | ||
x.setParent(this); | ||
} | ||
this.target = x; | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/main/java/com/alibaba/druid/sql/dialect/oscar/ast/stmt/OscarCreateSchemaStatement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright 1999-2017 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.druid.sql.dialect.oscar.ast.stmt; | ||
|
||
import com.alibaba.druid.sql.ast.SQLStatementImpl; | ||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr; | ||
import com.alibaba.druid.sql.ast.statement.SQLCreateStatement; | ||
import com.alibaba.druid.sql.dialect.oscar.visitor.OscarASTVisitor; | ||
import com.alibaba.druid.sql.dialect.postgresql.visitor.PGASTVisitor; | ||
import com.alibaba.druid.sql.visitor.SQLASTVisitor; | ||
|
||
public class OscarCreateSchemaStatement extends SQLStatementImpl implements OscarStatement, SQLCreateStatement { | ||
private SQLIdentifierExpr schemaName; | ||
private SQLIdentifierExpr userName; | ||
private boolean ifNotExists; | ||
private boolean authorization; | ||
|
||
public SQLIdentifierExpr getSchemaName() { | ||
return schemaName; | ||
} | ||
|
||
public void setSchemaName(SQLIdentifierExpr schemaName) { | ||
this.schemaName = schemaName; | ||
} | ||
|
||
public SQLIdentifierExpr getUserName() { | ||
return userName; | ||
} | ||
|
||
public void setUserName(SQLIdentifierExpr userName) { | ||
this.userName = userName; | ||
} | ||
|
||
public boolean isIfNotExists() { | ||
return ifNotExists; | ||
} | ||
|
||
public void setIfNotExists(boolean ifNotExists) { | ||
this.ifNotExists = ifNotExists; | ||
} | ||
|
||
public boolean isAuthorization() { | ||
return authorization; | ||
} | ||
|
||
public void setAuthorization(boolean authorization) { | ||
this.authorization = authorization; | ||
} | ||
|
||
protected void accept0(SQLASTVisitor visitor) { | ||
accept0((PGASTVisitor) visitor); | ||
} | ||
|
||
@Override | ||
public void accept0(OscarASTVisitor visitor) { | ||
if (visitor.visit(this)) { | ||
acceptChild(visitor, this.schemaName); | ||
acceptChild(visitor, this.userName); | ||
} | ||
visitor.endVisit(this); | ||
} | ||
} |
Oops, something went wrong.