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 2020/09/08 07:16:51 UTC

[GitHub] [shardingsphere] xbkaishui opened a new issue #7323: CREATE TABLE IF NOT EXISTS execute fail

xbkaishui opened a new issue #7323:
URL: https://github.com/apache/shardingsphere/issues/7323


   ## Bug Report
   
   `
   ### SQL: CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT AUTO_INCREMENT, user_id INT NOT NULL, address_id BIGINT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_id));
   ### Cause: org.apache.shardingsphere.sharding.route.engine.exception.TableExistsException: Table 't_order' already exists.
   	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434)
   	... 17 more
   Caused by: org.apache.shardingsphere.sharding.route.engine.exception.TableExistsException: Table 't_order' already exists.
   	at org.apache.shardingsphere.sharding.route.engine.validator.impl.ShardingCreateTableStatementValidator.preValidate(ShardingCreateTableStatementValidator.java:40)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingRouteDecorator.lambda$decorate$0(ShardingRouteDecorator.java:66)
   
   `
   
   **For English only**, other languages will not accept.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   5.0.0-RC1-SNAPSHOT
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   ### Expected behavior
   run and finish successfully 
   ### Actual behavior
   throws an exception 
   
   ### Reason analyze (If you can)
   The logic is in ShardingCreateTableStatementValidator.preValidate.  I think for it should not check if the create table contains   IF NOT EXISTS statement 
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   Run any the example module , with pre created table 
   


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



[GitHub] [shardingsphere] tristaZero commented on issue #7323: CREATE TABLE IF NOT EXISTS execute fail

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


   Hi @xbkaishui 
   
   Thanks for your feedback. It is unsupported at present, but it is not a difficult one from my perspective. Here is a simple solution from me.
   
   1. Add a boolean member like `isNotExisted` to `CreateTableStatement`
   2. Check this new table in `ShardingCreateTableStatementValidator` with `ShardingSphereMetaData`
   
   Welcome anyone interested in it to have a try!
   
   BTW, @strongduanmu Would you like to take charge of this one? 
   This is just a kind inquiry since I knew you are working on another important issue. If you are out of the time, we can ask the bits of help from the community. :-)
   
   Best,
   Trista


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



[GitHub] [shardingsphere] tristaZero commented on issue #7323: CREATE TABLE IF NOT EXISTS execute fail

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


   @xbkaishui It is not a very easy job for a newbie, but welcome to your initiative!
   If you need any help, please tell me.


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



[GitHub] [shardingsphere] tristaZero commented on issue #7323: CREATE TABLE IF NOT EXISTS execute fail

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


   > @tristaZero I am very sorry for the late reply and I think @xbkaishui can do a great job on this issue. 😀
   
   Yep, I believe that.
   Both of you are the significant force for the community. I hope you can enjoy yourselves with the OS community. :-)


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



[GitHub] [shardingsphere] strongduanmu commented on issue #7323: CREATE TABLE IF NOT EXISTS execute fail

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


   @tristaZero I am very sorry for the late reply and I think @xbkaishui  can do a great job on this issue. 😀
   


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



[GitHub] [shardingsphere] xbkaishui commented on issue #7323: CREATE TABLE IF NOT EXISTS execute fail

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


   Ok, 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:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero edited a comment on issue #7323: CREATE TABLE IF NOT EXISTS execute fail

Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on issue #7323:
URL: https://github.com/apache/shardingsphere/issues/7323#issuecomment-688811803


   @xbkaishui It is not a very easy job for a newbie, but welcome to your initiative. :-)
   If you need any help, please tell me.


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



[GitHub] [shardingsphere] tristaZero closed issue #7323: CREATE TABLE IF NOT EXISTS execute fail

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


   


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



[GitHub] [shardingsphere] xbkaishui commented on issue #7323: CREATE TABLE IF NOT EXISTS execute fail

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


   Please let me try, I am not familiar with the sql parser part. 


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