nameqxq opened a new issue #2853: I'm sure i only use mysql, can i only load 
mysql parse rule?
URL: https://github.com/apache/incubator-shardingsphere/issues/2853
 
 
   ## Feature Request
   
   **For English only**, other languages will not accept.
   
   Please pay attention on issues you submitted, because we maybe need more 
details. 
   If no response **more than 7 days** and we cannot make decision by current 
information, we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Is your feature request related to a problem?
   
   ### Describe the feature you would like.
   #### I'm sure i only use mysql, when i exclusions other database pom 
dependencies:
   ``` shell
       <dependency>
           <groupId>org.apache.shardingsphere</groupId>
           <artifactId>sharding-jdbc-core</artifactId>
           <version>${sharding-jdbc.version}</version>
           <exclusions>
               <exclusion>
                   <artifactId>sharding-core-parse-oracle</artifactId>
                   <groupId>org.apache.shardingsphere</groupId>
               </exclusion>
               <exclusion>
                   <artifactId>sharding-core-parse-postgresql</artifactId>
                   <groupId>org.apache.shardingsphere</groupId>
               </exclusion>
               <exclusion>
                   <artifactId>sharding-core-parse-sqlserver</artifactId>
                   <groupId>org.apache.shardingsphere</groupId>
               </exclusion>
           </exclusions>
       </dependency>
   ```
   
   #### Then start project:
   ``` java
       java.lang.NullPointerException: Cannot load extractor rule definition 
file 
:META-INF/parsing-rule-definition/sharding/postgresql/extractor-rule-definition.xml,
 
           at 
com.google.common.base.Preconditions.checkNotNull(Preconditions.java:250)
           at 
org.apache.shardingsphere.core.parse.antlr.rule.jaxb.loader.extractor.ExtractorRuleDefinitionEntityLoader.load(ExtractorRuleDefinitionEntityLoader.java:39)
           at 
org.apache.shardingsphere.core.parse.antlr.rule.registry.ParsingRuleRegistry.initParserRuleDefinition(ParsingRuleRegistry.java:102)
           at 
org.apache.shardingsphere.core.parse.antlr.rule.registry.ParsingRuleRegistry.initParserRuleDefinitionFromCommon(ParsingRuleRegistry.java:93)
           at 
org.apache.shardingsphere.core.parse.antlr.rule.registry.ParsingRuleRegistry.initParserRuleDefinition(ParsingRuleRegistry.java:77)
           at 
org.apache.shardingsphere.core.parse.antlr.rule.registry.ParsingRuleRegistry.init(ParsingRuleRegistry.java:57)
           at 
org.apache.shardingsphere.core.parse.antlr.rule.registry.ShardingParsingRuleRegistry.getInstance(ShardingParsingRuleRegistry.java:47)
           at 
org.apache.shardingsphere.core.parse.antlr.AntlrParsingEngine.<init>(AntlrParsingEngine.java:58)
           at 
org.apache.shardingsphere.core.parse.old.parser.sql.SQLParserFactory.newInstance(SQLParserFactory.java:81)
           at 
org.apache.shardingsphere.core.parse.SQLParsingEngine.parse(SQLParsingEngine.java:61)
           ...
   ```
   
   #### So... can we do this in 
org.apache.shardingsphere.core.parse.antlr.AntlrParsingEngine#AntlrParsingEngine
   ``` java
       public AntlrParsingEngine(final DatabaseType databaseType, final String 
sql, final BaseRule rule, final ShardingTableMetaData shardingTableMetaData) {
           // i want expand ParsingRuleRegistry and override 
needParser(databaseType) 
           // to determine which databases parse rules I need to load ;
           // and configuration use it, like this:
           // 
           // spring.sharding.customizeParsingRuleRegistry: 
XxxParsingRuleRegistry
           // 
           // or only give a config propertis to declare which databases parse 
rule need to be loaded:
           // 
           // spring.sharding.loadParsingRules: mysql,oracle,...
   
           parsingRuleRegistry = rule instanceof EncryptRule ? 
EncryptParsingRuleRegistry.getInstance() : 
ShardingParsingRuleRegistry.getInstance();
           parserEngine = new SQLParserEngine(parsingRuleRegistry, 
databaseType, sql);
           extractorEngine = new SQLSegmentsExtractorEngine();
           fillerEngine = new SQLStatementFillerEngine(parsingRuleRegistry, 
databaseType, sql, rule, shardingTableMetaData);
           optimizerEngine = new 
SQLStatementOptimizerEngine(shardingTableMetaData);
       }
   ```
   
   
   #### many, thanks

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to