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 2019/10/28 03:20:07 UTC

[GitHub] [incubator-shardingsphere] ilemonchn opened a new issue #3382: Throws "Table xxx not found" Exception when subquery's tableName should be rewrited.

ilemonchn opened a new issue #3382: Throws "Table xxx not found" Exception when subquery's tableName should be rewrited.
URL: https://github.com/apache/incubator-shardingsphere/issues/3382
 
 
   ## Bug Report
   
   
   ### Which version of ShardingSphere did you use?
   
   4.0.0-RC3-SNAPSHOT
   
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   
   Sharding-JDBC
   
   ### Expected behavior
   
   Correctly rewrite the subquery's tableName without Exception.
   
   ### Actual behavior
   
   Subquery's tableName isn't rewrited, which result in the "Table xxx not found" Exception.
   
   ### Reason analyze (If you can)
   
   The SQLSegmentExtractor extracts SQLSegments from the AST. However, the TableReferencesExtractor only extract the first TableReferencesContext node. When the subquery's TableReferencesContext did not included in the first TableReferencesContext node will result in the Exception.
   <img width="1319" alt="图片" src="https://user-images.githubusercontent.com/32984773/67649451-2394fd00-f974-11e9-8917-6da7cadc8dc1.png">
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   Write the test below in the context of ShardingPreparedStatementTest.class, then execute it.
   `String sql = "SELECT * FROM t_order_item WHERE status IN (SELECT status FROM t_order WHERE user_id = 10 AND order_id = 1000)";
   try (PreparedStatement preparedStatement = getShardingDataSource().getConnection().prepareStatement(sql)) {
   ResultSet resultSet = preparedStatement.executeQuery();
   }`

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


With regards,
Apache Git Services