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 2021/10/26 02:48:17 UTC

[GitHub] [shardingsphere] ulyChou opened a new issue #13273: Failed to delete table data due to alias

ulyChou opened a new issue #13273:
URL: https://github.com/apache/shardingsphere/issues/13273


   ## Bug Report
   Thank you first for your contribution to Shardingsphere :+1: :+1: :+1: 
   ### Which version of ShardingSphere did you use?
   v4.1.1
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   ### Expected behavior
   A single table with an alias should also be deleted successfully
   ### Actual behavior
   A single table with an alias failed to be deleted
   #11449 
   @Yule-Momoko
   ### Reason analyze (If you can)
   The alias was resolved to multiple tables, causing deletion failure
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   I have a sharded table `order_item`&`sharding-column=order_id`
   When I want to delete the data of the specified OrderItem table based on order_id: `delete from order_item where order_id = ?`
   ShadingJDBC is correct for execution : `delete from order_item_202110 where order_id = ?` :+1: 
   
   But let me use the ORM framework to generate SQL with alias : `delete t0 from oms_order_item t0 where t0.order_id  = ? `
   ```
   org.apache.shardingsphere.underlying.common.exception.ShardingSphereException: Cannot support Multiple-Table for 'org.apache.shardingsphere.sql.parser.sql.statement.dml.DeleteStatement@51c6d664'.
   	at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route(ShardingStandardRoutingEngine.java:72) ~[sharding-core-route-4.1.1.jar:4.1.1]
   	at org.apache.shardingsphere.sharding.route.engine.ShardingRouteDecorator.decorate(ShardingRouteDecorator.java:69) ~[sharding-core-route-4.1.1.jar:4.1.1]
   	at org.apache.shardingsphere.sharding.route.engine.ShardingRouteDecorator.decorate(ShardingRouteDecorator.java:53) ~[sharding-core-route-4.1.1.jar:4.1.1]
   	at org.apache.shardingsphere.underlying.route.DataNodeRouter.executeRoute(DataNodeRouter.java:91) ~[shardingsphere-route-4.1.1.jar:4.1.1]
   	at org.apache.shardingsphere.underlying.route.DataNodeRouter.route(DataNodeRouter.java:76) ~[shardingsphere-route-4.1.1.jar:4.1.1]
   	at org.apache.shardingsphere.underlying.pluggble.prepare.PreparedQueryPrepareEngine.route(PreparedQueryPrepareEngine.java:54) ~[shardingsphere-pluggable-4.1.1.jar:4.1.1]
   	at org.apache.shardingsphere.underlying.pluggble.prepare.BasePrepareEngine.executeRoute(BasePrepareEngine.java:96) ~[shardingsphere-pluggable-4.1.1.jar:4.1.1]
   	at org.apache.shardingsphere.underlying.pluggble.prepare.BasePrepareEngine.prepare(BasePrepareEngine.java:83) ~[shardingsphere-pluggable-4.1.1.jar:4.1.1]
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.prepare(ShardingPreparedStatement.java:183) ~[sharding-jdbc-core-4.1.1.jar:4.1.1]
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.executeUpdate(ShardingPreparedStatement.java:131) ~[sharding-jdbc-core-4.1.1.jar:4.1.1]
   	at io.ebeaninternal.server.persist.ExeUpdateSql.execute(ExeUpdateSql.java:42) ~[ebean-core-12.12.3.jar:na]
   	at io.ebeaninternal.server.persist.DefaultPersistExecute.executeSqlUpdate(DefaultPersistExecute.java:91) ~[ebean-core-12.12.3.jar:na]
   	at io.ebeaninternal.server.core.PersistRequestUpdateSql.executeNow(PersistRequestUpdateSql.java:84) ~[ebean-core-12.12.3.jar:na]
   	at io.ebeaninternal.server.core.PersistRequest.executeStatement(PersistRequest.java:138) ~[ebean-core-12.12.3.jar:na]
   	at io.ebeaninternal.server.core.PersistRequest.executeStatement(PersistRequest.java:122) ~[ebean-core-12.12.3.jar:na]
   	at io.ebeaninternal.server.core.PersistRequestUpdateSql.executeOrQueue(PersistRequestUpdateSql.java:94) ~[ebean-core-12.12.3.jar:na]
   	at io.ebeaninternal.server.persist.DefaultPersister.executeOrQueue(DefaultPersister.java:81) ~[ebean-core-12.12.3.jar:na]
   	at io.ebeaninternal.server.persist.DefaultPersister.executeSqlUpdate(DefaultPersister.java:130) ~[ebean-core-12.12.3.jar:na]
   	at io.ebeaninternal.server.core.DefaultServer.execute(DefaultServer.java:1942) ~[ebean-core-12.12.3.jar:na]
   	at io.ebeaninternal.server.core.DefaultServer.execute(DefaultServer.java:1965) ~[ebean-core-12.12.3.jar:na]
   	at io.ebeaninternal.server.core.DefaultSqlUpdate.execute(DefaultSqlUpdate.java:143) ~[ebean-core-12.12.3.jar:na]
   ```


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero closed issue #13273: Failed to delete table data due to alias

Posted by GitBox <gi...@apache.org>.
tristaZero closed issue #13273:
URL: https://github.com/apache/shardingsphere/issues/13273


   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on issue #13273: Failed to delete table data due to alias

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #13273:
URL: https://github.com/apache/shardingsphere/issues/13273#issuecomment-952589691


   @ulyChou Thank you very much for your feedback, it seems that something went wrong when rewriting. I will reopen this issue and fix this bug as soon as possible.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on issue #13273: Failed to delete table data due to alias

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #13273:
URL: https://github.com/apache/shardingsphere/issues/13273#issuecomment-951523752


   Hi @ulyChou, I have checked the master branch, this bug has been fixed, you can try the latest version.
   I will close this issue first. If there are other issues with the new version, please submit issue feedback.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] ulyChou commented on issue #13273: Failed to delete table data due to alias

Posted by GitBox <gi...@apache.org>.
ulyChou commented on issue #13273:
URL: https://github.com/apache/shardingsphere/issues/13273#issuecomment-952586019


   Hi @strongduanmu,I got the latest version and tried again.
   
   
   1.When I execute sql without an alias 👍 
   ```
   delete from oms_order_item where order_id = ?
    ```
   ```
   2021-10-27 14:32:37.828  INFO 361528 --- [nio-8500-exec-1] ShardingSphere-SQL                       : Logic SQL: delete from oms_order_item where order_id = ?
   2021-10-27 14:32:37.828  INFO 361528 --- [nio-8500-exec-1] ShardingSphere-SQL                       : SQLStatement: MySQLDeleteStatement(orderBy=Optional.empty, limit=Optional.empty)
   2021-10-27 14:32:37.828  INFO 361528 --- [nio-8500-exec-1] ShardingSphere-SQL                       : Actual SQL: ds ::: delete from oms_order_item_202110 where order_id = ? ::: [658646623312130048]
   ```
   
   
   2. when I execute sql with an alias
   ```
   delete t0 from oms_order_item t0 where t0.order_id  = ? 
   ```
   ```
   2021-10-27 14:29:02.075  INFO 361528 --- [nio-8500-exec-7] ShardingSphere-SQL                       : Logic SQL: delete t0 from oms_order_item t0 where t0.order_id  = ?
   2021-10-27 14:29:02.075  INFO 361528 --- [nio-8500-exec-7] ShardingSphere-SQL                       : SQLStatement: MySQLDeleteStatement(orderBy=Optional.empty, limit=Optional.empty)
   2021-10-27 14:29:02.075  INFO 361528 --- [nio-8500-exec-7] ShardingSphere-SQL                       : Actual SQL: ds ::: delete t0 from oms_order_item t0 where t0.order_id  = ? ::: [658646623312130048]
   
   javax.persistence.PersistenceException: Table 'erp_oms.oms_order_item' doesn't exist...
   ```
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] ulyChou commented on issue #13273: Failed to delete table data due to alias

Posted by GitBox <gi...@apache.org>.
ulyChou commented on issue #13273:
URL: https://github.com/apache/shardingsphere/issues/13273#issuecomment-952587109


   @strongduanmu Well, this is not the result I expected. I feel that there is still no effective repair for this problem. Please test the latest implementation again , thank u ~


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on issue #13273: Failed to delete table data due to alias

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #13273:
URL: https://github.com/apache/shardingsphere/issues/13273#issuecomment-951510283


   @ulyChou Thank you for your feedback, I will check it on master branch.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu closed issue #13273: Failed to delete table data due to alias

Posted by GitBox <gi...@apache.org>.
strongduanmu closed issue #13273:
URL: https://github.com/apache/shardingsphere/issues/13273


   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org