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/07/09 08:58:32 UTC

[GitHub] [shardingsphere] JonasGao opened a new issue #11251: Why is the exception of my SQL execution not thrown out

JonasGao opened a new issue #11251:
URL: https://github.com/apache/shardingsphere/issues/11251


   ## Question
   
   When I migrated the legacy code, I did not pay attention to the table structure is not suitable for sharding. 
   After completing the Sharding configuration. I test my code. It is an insert operation. I found that it did not report an error, but returned the number of affected rows "-1". I was confused at the time. After many attempts, I amended the table structure. Normally, SQLException will be thrown in this case. 
   Afterwards, I briefly read the source code.
   So, why does JDBCExecutorCallback not throw SQLException
   
   Let's give a chestnut 🙋‍♂️
   
   ```
   CREATE TABLE ht_supply_price_sku_adjust
   (
       id INT AUTO_INCREMENT PRIMARY KEY,
       sku VARCHAR(100) NOT NULL
   )
   ```
   
   And use default key generate strategy. Default key is of type LONG. INT will fail. 
   Now when you insert into some table like `ht_supply_price_sku_adjust_01`. it will return -1
   
   The source code is there
   ```
   public abstract class JDBCExecutorCallback<T> implements ExecutorCallback<JDBCExecutionUnit, T> {
       private T execute(JDBCExecutionUnit jdbcExecutionUnit, boolean isTrunkThread, Map<String, Object> dataMap) throws SQLException {
          ...
           try {
               ...
           } catch (SQLException var8) {
               // why not throw the var8
               if (!isTrunkThread) {
                   return null;
               } else {
                   Optional<T> saneResult = this.getSaneResult(this.sqlStatement);
                   if (saneResult.isPresent()) {
                       return saneResult.get();
                   } else {
                       sqlExecutionHook.finishFailure(var8);
                       SQLExecutorExceptionHandler.handleException(var8);
                       return null;
                   }
               }
           }
       }
   }
   ```


-- 
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] JonasGao closed issue #11251: Why is the exception of my SQL execution not thrown out

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


   


-- 
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] RaigorJiang commented on issue #11251: Why is the exception of my SQL execution not thrown out

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


   Hi @JonasGao 
   Please refer to #10844 , You can try the latest version by build 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] tristaZero commented on issue #11251: Why is the exception of my SQL execution not thrown out

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


   @JonasGao I stand @RaigorJiang . Plus, your 🙋‍♂️  ... looks cute.


-- 
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] JonasGao commented on issue #11251: Why is the exception of my SQL execution not thrown out

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


   @RaigorJiang Nice. I will try later.


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