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/11/14 06:57:22 UTC

[GitHub] [incubator-shardingsphere] gfreezy opened a new issue #3523: Create table sql not works

gfreezy opened a new issue #3523: Create table sql not works
URL: https://github.com/apache/incubator-shardingsphere/issues/3523
 
 
   ## Bug Report
   ```java
   Exception in thread "main" java.lang.NullPointerException
   	at org.apache.shardingsphere.core.execute.sql.execute.result.StreamQueryResult.<init>(StreamQueryResult.java:49)
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.getResultSet(ShardingPreparedStatement.java:136)
   	at org.jetbrains.exposed.sql.Transaction$exec$2.executeInternal(Transaction.kt:107)
   	at org.jetbrains.exposed.sql.statements.Statement.executeIn$exposed(Statement.kt:59)
   	at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:183)
   	at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:125)
   	at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:101)
   	at org.jetbrains.exposed.sql.Transaction.exec(Transaction.kt:92)
   	at com.xiachufang.DbUtilsKt.dropTables(DbUtils.kt:22)
   	at com.xiachufang.DatasourceKt$main$1.invoke(Datasource.kt:51)
   	at com.xiachufang.DatasourceKt$main$1.invoke(Datasource.kt)
   	at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt$inTopLevelTransaction$1.invoke(ThreadLocalTransactionManager.kt:156)
   	at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt$inTopLevelTransaction$2.invoke(ThreadLocalTransactionManager.kt:197)
   	at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.keepAndRestoreTransactionRefAfterRun(ThreadLocalTransactionManager.kt:205)
   	at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.inTopLevelTransaction(ThreadLocalTransactionManager.kt:196)
   	at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt$transaction$1.invoke(ThreadLocalTransactionManager.kt:134)
   	at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.keepAndRestoreTransactionRefAfterRun(ThreadLocalTransactionManager.kt:205)
   	at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:106)
   	at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:104)
   	at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction$default(ThreadLocalTransactionManager.kt:103)
   	at com.xiachufang.DatasourceKt.main(Datasource.kt:50)
   	at com.xiachufang.DatasourceKt.main(Datasource.kt)
   ```
   
   ### Which version of ShardingSphere did you use?
   4.0.0-RC2 4.0.0-RC3
   
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   Sharding-JDBC
   
   ### Expected behavior
   ```sql
   CREATE TABLE IF NOT EXISTS board (id BIGINT PRIMARY KEY, author_id BIGINT NOT NULL, title VARCHAR(100) NOT NULL, description VARCHAR(1000) NOT NULL, status INT NOT NULL, accessibility INT NOT NULL, create_time DATETIME(6) NOT NULL, update_time DATETIME(6) NOT NULL)
   ```
   
   Failed.
   
   ### Actual behavior
   It should create the table.
   
   ### Reason analyze (If you can)
   `StreamQueryResult`  did not consider `resultSet` to be null. When executing create table sql, resultSet will be null.
   
   ```java
   public final class StreamQueryResult implements QueryResult {
       
       private final QueryResultMetaData metaData;
       
       private final ResultSet resultSet;
       
       @SneakyThrows
       public StreamQueryResult(final ResultSet resultSet, final ShardingRule shardingRule) {
           this.resultSet = resultSet;
           metaData = new QueryResultMetaData(resultSet.getMetaData(), shardingRule);
       }
       
       @SneakyThrows
       public StreamQueryResult(final ResultSet resultSet, final EncryptRule encryptRule) {
           this.resultSet = resultSet;
           metaData = new QueryResultMetaData(resultSet.getMetaData(), encryptRule);
       }
       
       @SneakyThrows
       public StreamQueryResult(final ResultSet resultSet) {
           this.resultSet = resultSet;
           metaData = new QueryResultMetaData(resultSet.getMetaData());
       }
       
   ```
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   Execute the following sql should reproduce the problem.
   
   ```sql
   CREATE TABLE IF NOT EXISTS board (id BIGINT PRIMARY KEY, author_id BIGINT NOT NULL, title VARCHAR(100) NOT NULL, description VARCHAR(1000) NOT NULL, status INT NOT NULL, accessibility INT NOT NULL, create_time DATETIME(6) NOT NULL, update_time DATETIME(6) NOT NULL)
   ```
   
   ### 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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services