sccc803 opened a new issue, #14349:
URL: https://github.com/apache/shardingsphere/issues/14349
### Which version of ShardingSphere did you use?
Master branch.
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-Proxy
### Expected behavior
Here is a logic table called t_order, show create table:
CREATE TABLE `t_order` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`order_id` int(11) unsigned DEFAULT NULL,
`name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
Insert a record:
``` sql
INSERT INTO t_order VALUES(1,4294967295,'name');
```
Import MySQL Connector/J v8.x
```xml
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
```
Then execute JDBC code below,
``` java
Connection conn = DriverManager.getConnection("jdbc:mysql://xxx",
"username", "password");
PreparedStatement pstmt = conn.prepareStatement("select * from t_order");
return pstmt.executeQuery();
```
It supposed to return the correct result like this:
id | order_id | name
-- | -- | --
1| 4294967295 | name
### Actual behavior
Retrun a wrong result:
id | order_id | name
-- | -- | --
1| -1 | name
### Reason analyze (If you can)
When a client sends a COM_STMT_PREPARE packet to a Shardingsphere-Proxy, it
sends back some fake packets whose field "flag" is hardcoded by 0.
```java
public MySQLColumnDefinition41Packet(final int sequenceId, final int
characterSet, final String schema, final String table, final String orgTable,
final String name, final String
orgName, final int columnLength, final MySQLBinaryColumnType columnType,
final int decimals, final boolean
containDefaultValues) {
this(sequenceId, characterSet, 0, schema, table, orgTable, name,
orgName, columnLength, columnType, decimals, containDefaultValues);
}
```
In MySQL Connector/J 8.x, these fake packets are unpacked and cached to
create thie columnn definition packets whitch will be sent back to client, so
this problem occurs.
And this problem is not exist in MySQL Connector/J 5.x.
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule
configuration, when exception occur etc.
1. Set configuration of Proxy:
```yaml
schemaName: sharding_db
dataSources:
ds_0:
url: jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC&useSSL=false
username: username
password: password
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
rules:
- !SHARDING
tables:
t_order:
actualDataNodes: ds_0.t_order_${0..1}
tableStrategy:
standard:
shardingColumn: order_id
shardingAlgorithmName: t_order_inline
keyGenerateStrategy:
column: order_id
keyGeneratorName: snowflake
shardingAlgorithms:
t_order_inline:
type: INLINE
props:
algorithm-expression: t_order_${order_id % 2}
keyGenerators:
snowflake:
type: SNOWFLAKE
props:
worker-id: 123
```
2. Create t_order_0 , t_order_1 on ds_0:
``` sql
CREATE TABLE `t_order` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`order_id` int(11) unsigned DEFAULT NULL,
`name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
```
3. Start up proxy, and execute insert statement:
``` sql
INSERT INTO t_order VALUES(1,4294967295,'name');
```
4. Import MySQL Connector/J v8.x
```xml
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
```
5. Execute JDBC query with PrepareStamentment:
``` java
Connection conn =
DriverManager.getConnection("jdbc:mysql://127.0.0.1:3307/sharding_db?useServerPrepStmts=true&&useSSL=false",
"username", "password");
PreparedStatement pstmt = conn.prepareStatement("select * from t_order");
return pstmt.executeQuery();
```
### 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.
To unsubscribe, e-mail:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]