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/11/13 15:38:20 UTC

[GitHub] [shardingsphere] wenweibin commented on issue #7791: Improve mysql Statemen definition and Visitor

wenweibin commented on issue #7791:
URL: https://github.com/apache/shardingsphere/issues/7791#issuecomment-726833383


   Firstlly, I'm going to start with `MySQLDropTableStatement` of subtask 4.According the synax of dropTable in DDLStatement.g4, I think the refactor is like below:
   
   
   1. Revise `MySQLDropTableStatement`  class
   ``` 
   /**
    * MySQL drop table statement.
    */
   @ToString
   @Getter
   @Setter
   public final class MySQLDropTableStatement extends DropTableStatement implements MySQLStatement {
       
       private boolean temporary;
       
       private boolean isExisted;
       
       private Restrict restrict;
       
   }
   ```
   
   2. Add `Restrict`  enum
   ```
   /**
    * Restrict type enum.
    */
   public enum Restrict {
       
       RESTRICT, CASCADE
   }
   ```
   3. Revise `MySQLDDLStatementSQLVisitor` visitDropTable method
   ```
      @Override
       public ASTNode visitDropTable(final DropTableContext ctx) {
           MySQLDropTableStatement result = new MySQLDropTableStatement();
           result.setTemporary(Objects.nonNull(ctx.TEMPORARY()));
           result.setExisted(Objects.nonNull(ctx.existClause()));
           if (null != ctx.restrict()) {
               result.setRestrict(Objects.nonNull(ctx.restrict()) ? Restrict.RESTRICT : Restrict.CASCADE);
           }
           result.getTables().addAll(((CollectionValue<SimpleTableSegment>) visit(ctx.tableNames())).getValue());
           return result;
       }
   ````
   
   Can you give some suggestions?@jingshanglu


----------------------------------------------------------------
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