Skip to content

Commit

Permalink
Optimize oracle select statement parsing speed
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingZC committed Sep 26, 2023
1 parent 898dcc9 commit 69b06e6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,7 @@ select
;

selectSubquery
: (queryBlock | selectCombineClause | parenthesisSelectSubquery) pivotClause? orderByClause? rowLimitingClause
;

selectCombineClause
: ((queryBlock | parenthesisSelectSubquery) orderByClause? rowLimitingClause) ((UNION ALL? | INTERSECT | MINUS) selectSubquery)+
: (queryBlock | parenthesisSelectSubquery) ((UNION ALL? | INTERSECT | MINUS) selectSubquery)? orderByClause?
;

parenthesisSelectSubquery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.QueryTableExprContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ReferenceModelContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.RollupCubeClauseContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.SelectCombineClauseContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.SelectContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.SelectFromClauseContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.SelectJoinOptionContext;
Expand Down Expand Up @@ -530,8 +529,6 @@ public ASTNode visitSelectSubquery(final SelectSubqueryContext ctx) {
OracleSelectStatement result;
if (null != ctx.queryBlock()) {
result = (OracleSelectStatement) visit(ctx.queryBlock());
} else if (null != ctx.selectCombineClause()) {
result = (OracleSelectStatement) visit(ctx.selectCombineClause());
} else {
result = (OracleSelectStatement) visit(ctx.parenthesisSelectSubquery());
}
Expand Down Expand Up @@ -643,23 +640,6 @@ public ASTNode visitReferenceModel(final ReferenceModelContext ctx) {
return new SubquerySegment(ctx.selectSubquery().start.getStartIndex(), ctx.selectSubquery().stop.getStopIndex(), subquery);
}

@Override
public ASTNode visitSelectCombineClause(final SelectCombineClauseContext ctx) {
OracleSelectStatement result;
if (null != ctx.queryBlock()) {
result = (OracleSelectStatement) visit(ctx.queryBlock());
} else {
result = (OracleSelectStatement) visit(ctx.parenthesisSelectSubquery());
}
if (null != ctx.orderByClause()) {
result.setOrderBy((OrderBySegment) visit(ctx.orderByClause()));
}
for (SelectSubqueryContext each : ctx.selectSubquery()) {
visit(each);
}
return result;
}

@Override
public ASTNode visitParenthesisSelectSubquery(final ParenthesisSelectSubqueryContext ctx) {
return visit(ctx.selectSubquery());
Expand Down

0 comments on commit 69b06e6

Please sign in to comment.