Open xiangsong97 opened 3 months ago
经测试,1.1.8-alpha-3没有此问题
测试语句和输出如下
DROP TABLE IF EXISTS `tb_tinyint`;
CREATE TABLE tb_tinyint (
id int NOT NULL AUTO_INCREMENT COMMENT '主键',
user_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用户名称',
col2 tinyint(1) DEFAULT NULL COMMENT 'col2',
PRIMARY KEY (id) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='测试表';
insert into tb_tinyint (user_name, col2) values ('张三', 1);
insert into tb_tinyint (user_name, col2) values ('李四', -1);
insert into tb_tinyint (user_name, col2) values ('王五', 100);
insert into tb_tinyint (user_name, col2) values ('赵六', 0);
ca1-1 | 2024-10-24 16:47:36.598 [pool-3-thread-1] INFO c.a.o.canal.client.adapter.logger.LoggerAdapterExample - DML: {"data":null,"database":"mytest2","destination":"mytest2","es":1729759656000,"groupId":"mytest2","isDdl":true,"old":null,"pkNames":null,"sql":"DROP TABLE IF EXISTS `tb_tinyint` /* generated by server */","table":"tb_tinyint","ts":1729759656596,"type":"ERASE"}
ca1-1 | 2024-10-24 16:47:36.600 [pool-3-thread-1] INFO c.a.o.canal.client.adapter.logger.LoggerAdapterExample - DML: {"data":null,"database":"mytest2","destination":"mytest2","es":1729759656000,"groupId":"mytest2","isDdl":true,"old":null,"pkNames":null,"sql":"CREATE TABLE tb_tinyint (\r\n id int NOT NULL AUTO_INCREMENT COMMENT '主键',\r\n user_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用户名称',\r\n col2 tinyint(1) DEFAULT NULL COMMENT 'col2',\r\n PRIMARY KEY (id) USING BTREE\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='测试表'","table":"tb_tinyint","ts":1729759656596,"type":"CREATE"}
ca1-1 | 2024-10-24 16:47:36.600 [pool-3-thread-1] INFO c.a.o.canal.client.adapter.logger.LoggerAdapterExample - DML: {"data":[{"user_name":"张三","id":"1","col2":"1"}],"database":"mytest2","destination":"mytest2","es":1729759656000,"groupId":"mytest2","isDdl":false,"old":null,"pkNames":["id"],"sql":"","table":"tb_tinyint","ts":1729759656596,"type":"INSERT"}
ca1-1 | 2024-10-24 16:47:36.600 [pool-3-thread-1] INFO c.a.o.canal.client.adapter.logger.LoggerAdapterExample - DML: {"data":[{"user_name":"李四","id":"2","col2":"-1"}],"database":"mytest2","destination":"mytest2","es":1729759656000,"groupId":"mytest2","isDdl":false,"old":null,"pkNames":["id"],"sql":"","table":"tb_tinyint","ts":1729759656596,"type":"INSERT"}
ca1-1 | 2024-10-24 16:47:36.600 [pool-3-thread-1] INFO c.a.o.canal.client.adapter.logger.LoggerAdapterExample - DML: {"data":[{"user_name":"王五","id":"3","col2":"100"}],"database":"mytest2","destination":"mytest2","es":1729759656000,"groupId":"mytest2","isDdl":false,"old":null,"pkNames":["id"],"sql":"","table":"tb_tinyint","ts":1729759656596,"type":"INSERT"}
ca1-1 | 2024-10-24 16:47:36.600 [pool-3-thread-1] INFO c.a.o.canal.client.adapter.logger.LoggerAdapterExample - DML: {"data":[{"user_name":"赵六","id":"4","col2":"0"}],"database":"mytest2","destination":"mytest2","es":1729759656000,"groupId":"mytest2","isDdl":false,"old":null,"pkNames":["id"],"sql":"","table":"tb_tinyint","ts":1729759656596,"type":"INSERT"}
environment
canal-admin ,adapter,server 版本1.8
Issue Description
源库中为tinyint(1)的字段,在目标库也是tinyint(1)类型,同步时,只要有值就会变成1,不管值是多少。 adapter的消费日志是正常的
mysql的binlog日志永远是1 问题找了好久,发现了只要把类型修改为int类型,并且重启adapter和servert后获取的值才正常。刚开始就觉得是数据类型的原因,但是没重启adapter,就以为不是数据类型的问题,后来看源码才知道有缓存,才重启了
Steps to reproduce
Expected behaviour
Actual behaviour
If there is an exception, please attach the exception trace: