chenshao6311 opened a new issue #1763: The correct result cannot be found when 
the binding table is associated with the query
URL: https://github.com/apache/incubator-shardingsphere/issues/1763
 
 
   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub 
issues](https://github.com/sharding-sphere/sharding-sphere/issues).
   - Read documentation: [ShardingSphere 
Doc](http://shardingsphere.io/document/current/en/overview/).
   
   Please pay attention on issues you submitted, because we maybe need more 
details. 
   If no response **more than 7 days** and we cannot reproduce it on current 
information, we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   3.1.0
   
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   Sharding-JDBC
   
   ### Expected behavior
   String sql = "SELECT i.* FROM t_order o, t_order_item i WHERE o.order_id = 
i.order_id and o.order_id = 292325090350071808";
   
   ### Actual behavior
   can find result,but no result return 
   
   ### Reason analyze (If you can)
   
   When the queries are associated with two bound tables, I don't understand 
why the corresponding dataNode can be found through the main table, then the 
index can be found through the dataNode, and finally the dataNode of another 
table can be determined by the index.            
   As long as the order of dataNodes I configure is different, the results of 
the association query are incorrect.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   private static TableRuleConfiguration getOrderItemTableRuleConfiguration() {
   TableRuleConfiguration result = new TableRuleConfiguration();
   result.setLogicTable("t_order_item");
   
result.setActualDataNodes("demo_ds_0.t_order_item_1,demo_ds_0.t_order_item_0,demo_ds_1.t_order_item_1,demo_ds_1.t_order_item_0");
   //result.setActualDataNodes("demo_ds_${0..1}.t_order_item_${[0, 1]}");
   return result;
   }
   private static TableRuleConfiguration getOrderTableRuleConfiguration() {
   TableRuleConfiguration result = new TableRuleConfiguration();
   result.setLogicTable("t_order");
   result.setActualDataNodes("demo_ds_${0..1}.t_order_${[0, 1]}");
   result.setKeyGeneratorColumnName("order_id");
   return result;
   }
   shardingRuleConfig.getBindingTableGroups().add("t_order, t_order_item");
   shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new 
InlineShardingStrategyConfiguration("user_id", "demo_ds_${user_id % 2}"));
   shardingRuleConfig.setDefaultTableShardingStrategyConfig(new 
StandardShardingStrategyConfiguration("order_id", new 
PreciseModuloShardingTableAlgorithm()));
   
   ### Example codes for reproduce this issue (such as a github link).
   
   ###PS
   When the queries are associated with two bound tables, I don't understand 
why the corresponding dataNode can be found through the main table, then the 
index can be found through the dataNode, and finally the dataNode of another 
table can be determined by the index.            As long as the order of 
dataNodes I configure is different, the results of the association query are 
incorrect. For example:            My configuration: 
   
   private static TableRuleConfiguration getOrderItemTableRuleConfiguration() {
   TableRuleConfiguration result = new TableRuleConfiguration();
   result.setLogicTable("t_order_item");
   
result.setActualDataNodes("demo_ds_0.t_order_item_1,demo_ds_0.t_order_item_0,demo_ds_1.t_order_item_1,demo_ds_1.t_order_item_0");
   //result.setActualDataNodes("demo_ds_${0..1}.t_order_item_${[0, 1]}");
   return result;
   }
   private static TableRuleConfiguration getOrderTableRuleConfiguration() {
   TableRuleConfiguration result = new TableRuleConfiguration();
   result.setLogicTable("t_order");
   result.setActualDataNodes("demo_ds_${0..1}.t_order_${[0, 1]}");
   result.setKeyGeneratorColumnName("order_id");
   return result;
   }
   shardingRuleConfig.getBindingTableGroups().add("t_order, t_order_item");
   shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new 
InlineShardingStrategyConfiguration("user_id", "demo_ds_${user_id % 2}"));
   shardingRuleConfig.setDefaultTableShardingStrategyConfig(new 
StandardShardingStrategyConfiguration("order_id", new 
PreciseModuloShardingTableAlgorithm()));
   
   If the data is inserted first and then the order_id is used as the query 
condition for the association query, the correct result will not be obtained.   
         
   
   By Finding Statements :
   String sql = "SELECT i.* FROM t_order o, t_order_item i WHERE o.order_id = 
i.order_id and o.order_id = 292325090350071808";
   
   The routing result is :
    "SELECT i.* FROM t_order_0 o, t_order_item_0 i WHERE o.order_id = 
i.order_id and o.order_id = 292325090350071808";

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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