TeslaCN opened a new issue #11602:
URL: https://github.com/apache/shardingsphere/issues/11602


   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   master
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   Proxy
   ### Expected behavior
   SQL routed to ds_3 only.
   
   ### Actual behavior
   
   ```yaml
       tables:
         bmsql_warehouse:
           actualDataNodes: ds_${0..3}.bmsql_warehouse
           databaseStrategy:
             standard:
               shardingColumn: w_id
               shardingAlgorithmName: bmsql_warehouse_database_inline
         bmsql_customer:
           actualDataNodes: ds_${0..3}.bmsql_customer
           databaseStrategy:
             standard:
               shardingColumn: c_w_id
               shardingAlgorithmName: bmsql_customer_database_inline
   
       bindingTables:
         - bmsql_warehouse, bmsql_customer
   
       shardingAlgorithms:
         bmsql_warehouse_database_inline:
           type: INLINE
           props:
             algorithm-expression: ds_${w_id & 3}
         bmsql_customer_database_inline:
           type: INLINE
           props:
             algorithm-expression: ds_${c_w_id & 3}
   ```
   
   ```
   [INFO ] 2021-08-02 17:25:42.997 [Connection-2-ThreadExecutor] 
ShardingSphere-SQL - Logic SQL: SELECT c_discount, c_last, c_credit, w_tax     
FROM bmsql_customer     JOIN bmsql_warehouse ON (w_id = c_w_id)     WHERE 
c_w_id = ? AND c_d_id = ? AND c_id = ?
   [INFO ] 2021-08-02 17:25:42.997 [Connection-2-ThreadExecutor] 
ShardingSphere-SQL - SQLStatement: 
PostgreSQLSelectStatement(limit=Optional.empty, lock=Optional.empty, 
window=Optional.empty)
   [INFO ] 2021-08-02 17:25:42.997 [Connection-2-ThreadExecutor] 
ShardingSphere-SQL - Actual SQL: ds_0 ::: SELECT c_discount, c_last, c_credit, 
w_tax     FROM bmsql_customer     JOIN bmsql_warehouse ON (w_id = c_w_id)     
WHERE c_w_id = ? AND c_d_id = ? AND c_id = ? ::: [23, 10, 1491]
   [INFO ] 2021-08-02 17:25:42.997 [Connection-2-ThreadExecutor] 
ShardingSphere-SQL - Actual SQL: ds_1 ::: SELECT c_discount, c_last, c_credit, 
w_tax     FROM bmsql_customer     JOIN bmsql_warehouse ON (w_id = c_w_id)     
WHERE c_w_id = ? AND c_d_id = ? AND c_id = ? ::: [23, 10, 1491]
   [INFO ] 2021-08-02 17:25:42.997 [Connection-2-ThreadExecutor] 
ShardingSphere-SQL - Actual SQL: ds_2 ::: SELECT c_discount, c_last, c_credit, 
w_tax     FROM bmsql_customer     JOIN bmsql_warehouse ON (w_id = c_w_id)     
WHERE c_w_id = ? AND c_d_id = ? AND c_id = ? ::: [23, 10, 1491]
   [INFO ] 2021-08-02 17:25:42.997 [Connection-2-ThreadExecutor] 
ShardingSphere-SQL - Actual SQL: ds_3 ::: SELECT c_discount, c_last, c_credit, 
w_tax     FROM bmsql_customer     JOIN bmsql_warehouse ON (w_id = c_w_id)     
WHERE c_w_id = ? AND c_d_id = ? AND c_id = ? ::: [23, 10, 1491]
   ```
   
   The `c_w_id` is a sharding column and the value is specified `23`. `23 & 3 = 
3`, I think this SQL should be routed to ds_3 only.
   
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   Using BenchmarkSQL can reproduce this issue.
   
   ### Example codes for reproduce this issue (such as a github link).
   


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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to