TeslaCN commented on a change in pull request #10132: URL: https://github.com/apache/shardingsphere/pull/10132#discussion_r615876833
########## File path: shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/ProxyJDBCExecutorCallback.java ########## @@ -85,7 +86,18 @@ private QueryResult createQueryResult(final ResultSet resultSet, final Connectio private long getGeneratedKey(final Statement statement) throws SQLException { ResultSet resultSet = statement.getGeneratedKeys(); - return resultSet.next() ? resultSet.getLong(1) : 0L; + return resultSet.next() ? getGeneratedKeyIfInteger(resultSet) : 0L; + } + + private long getGeneratedKeyIfInteger(final ResultSet resultSet) throws SQLException { + switch (resultSet.getMetaData().getColumnType(1)) { + case Types.SMALLINT: + case Types.INTEGER: Review comment: ## MySQL ``` MySQL Protocol Packet Length: 77 Packet Number: 0 Request Command Query Command: Query (3) Statement: insert into t_config_0 (config_name, config_value) values ('key2', 'value2') ``` ``` MySQL Protocol Packet Length: 7 Packet Number: 1 Response Code: OK Packet (0x00) Affected Rows: 1 Server Status: 0x0002 .... .... .... ...0 = In transaction: Not set .... .... .... ..1. = AUTO_COMMIT: Set .... .... .... .0.. = Multi query / Unused: Not set .... .... .... 0... = More results: Not set .... .... ...0 .... = Bad index used: Not set .... .... ..0. .... = No index used: Not set .... .... .0.. .... = Cursor exists: Not set .... .... 0... .... = Last row sent: Not set .... ...0 .... .... = Database dropped: Not set .... ..0. .... .... = No backslash escapes: Not set .... .0.. .... .... = Metadata changed: Not set .... 0... .... .... = Query was slow: Not set ...0 .... .... .... = PS Out Params: Not set ..0. .... .... .... = In Trans Readonly: Not set .0.. .... .... .... = Session state changed: Not set Message: ``` When using MySQL, it returned nothing about generated keys. So the `resultSet.next()` is `false`. -- 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: us...@infra.apache.org