You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/12/25 04:52:09 UTC

[GitHub] [shardingsphere] terrymanu commented on a change in pull request #8766: fix #8696 and adjust 'set' grammar

terrymanu commented on a change in pull request #8766:
URL: https://github.com/apache/shardingsphere/pull/8766#discussion_r548800714



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLTCLStatementSQLVisitor.java
##########
@@ -55,40 +53,30 @@ public MySQLTCLStatementSQLVisitor(final Properties props) {
     @Override
     public ASTNode visitSetTransaction(final SetTransactionContext ctx) {
         MySQLSetTransactionStatement result = new MySQLSetTransactionStatement();
-        if (null != ctx.scope()) {
-            ScopeContext scopeContext = ctx.scope();
-            if (null != scopeContext.GLOBAL()) {
-                result.setScope(scopeContext.GLOBAL().getText());
-            } else if (null != scopeContext.SESSION()) {
-                result.setScope(scopeContext.SESSION().getText());
-            }
+        if (null != ctx.optionType()) {
+            result.setScope(ctx.optionType().getText());
         }
-        if (null != ctx.transactionCharacteristic()) {
-            for (TransactionCharacteristicContext each : ctx.transactionCharacteristic()) {
-                if (null != each.level()) {
-                    result.setIsolationLevel(each.level().getText());
-                }
-                if (null != each.accessMode()) {
-                    result.setAccessMode(each.accessMode().getText());
-                }
-            }
+        if (null != ctx.transactionCharacteristics().isolationLevel()) {
+            result.setIsolationLevel(ctx.transactionCharacteristics().isolationLevel().isolationTypes().getText());
+        }
+        if (null != ctx.transactionCharacteristics().transactionAccessMode()) {
+            result.setAccessMode(ctx.transactionCharacteristics().transactionAccessMode().getText());
         }
         return new MySQLSetTransactionStatement();
     }
     
     @Override
     public ASTNode visitSetAutoCommit(final SetAutoCommitContext ctx) {
         MySQLSetAutoCommitStatement result = new MySQLSetAutoCommitStatement();
-        result.setAutoCommit(((AutoCommitSegment) visit(ctx.autoCommitValue())).isAutoCommit());
+        result.setAutoCommit(generateAutoCommitSegment(ctx.autoCommitValue).isAutoCommit());
         return result;
     }
-    
-    @Override
-    public ASTNode visitAutoCommitValue(final AutoCommitValueContext ctx) {
+
+    private AutoCommitSegment generateAutoCommitSegment(final Token ctx) {
         boolean autoCommit = "1".equals(ctx.getText()) || "ON".equals(ctx.getText());
-        return new AutoCommitSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), autoCommit);
+        return new AutoCommitSegment(ctx.getStartIndex(), ctx.getStopIndex(), autoCommit);
     }
-    
+

Review comment:
       Please do not change original indent




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org