BroFanta opened a new issue, #33784:
URL: https://github.com/apache/shardingsphere/issues/33784

   ## Question
   
   I first set up MySQL on port 3306 and created a database named 
_dis_database0_. Then, I set up MySQL2 on port 3308 and created another 
database named _dis_database1_. After that, I used ShardingSphere (port 3307) 
to connect these two databases. When I created the table _HuangHStu_ in 
ShardingSphere, corresponding sharded tables were automatically generated in 
both databases. However, when executing an INSERT statement, an error occurs. 
Please help me resolve this issue.
   
   ### Version information
   shardingsphere:apache-shardingsphere-5.4.1
   mysql:8.0.40
   
   ### config-sharding.yaml
   ```
   databaseName: sharding_db
    
   dataSources:
     ds_0:
       url: 
jdbc:mysql://127.0.0.1:3306/dis_database0?serverTimezone=UTC&useSSL=false
       username: root
       password: root
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
       minPoolSize: 1
     ds_1:
       url: 
jdbc:mysql://127.0.0.1:3308/dis_database1?serverTimezone=UTC&useSSL=false
       username: root
       password: root
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
       minPoolSize: 1
   rules:
   - !SHARDING
     tables:
       HuangHStu:
         actualDataNodes: ds_${0..1}.HuangHStu
         tableStrategy:
           standard:
             shardingColumn: Sno
             shardingAlgorithmName: Sno_inline
       HuangHSC:
         actualDataNodes: ds_${0..1}.HuangHSC
         tableStrategy:
           standard:
             shardingColumn: Sno
             shardingAlgorithmName: Sno_inline
     bindingTables:
       - HuangHStu,HuangHSC
     defaultDatabaseStrategy:
       none:
     defaultTableStrategy:
       none:
     shardingAlgorithms:
       Sno_inline:
         type: INLINE
         props:
           algorithm-expression: ds_${(Sno % 2).abs()}
   - !BROADCAST
     tables:
      - HuangHCou
   ```
   ### Series of operations
   I executed the following CREATE TABLE operation in sharding_db.
   ```
   CREATE TABLE if not exists HuangHStu (
       Sno INT PRIMARY KEY,          -- 学号,主键,长度最多为6
       Sname VARCHAR(50) NOT NULL,         -- 姓名,不允许为空
       Sdept VARCHAR(100),                 -- 学院
       Stel VARCHAR(15),                   -- 联系方式,建议格式为手机或电话号码
       Sex CHAR(1) CHECK (Sex IN ('M', 'F')), -- 性别,仅允许 'M'(男)或 'F'(女)
       Sage INT, -- 年龄,范围在 0-150
       Saddr VARCHAR(200),                 -- 家庭住址
       Spost VARCHAR(10)                   -- 邮编
   );
   ```
   The subsequent database state is shown in the image.
   
![image](https://github.com/user-attachments/assets/afca31d0-35d7-4c96-9dcb-65aa078c8d2b)
   
![image](https://github.com/user-attachments/assets/3c33fd77-fcad-4a90-b9ab-397a70162971)
   Next, I executed the following `INSERT` operation in `HuangHStu` within 
`sharding_db`.
   ```
   INSERT INTO HuangHStu (Sno, Sname, Sdept, Stel, Sex, Sage, Saddr, Spost)
   VALUES 
   (100001, '张三', '计算机学院', '13812345678', 'M', 20, '四川省成都市青羊区', '610000');
   ```
   An error occurred while executing the INSERT operation.
   
   
   
   ### Error details
   
![image](https://github.com/user-attachments/assets/0448441d-f3c8-4d42-b009-14ce05454bdc)
   
   


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

Reply via email to