开发者社区> 问答> 正文

mysql text/longtext类型在解析时被识别为LONGVARBINARY,导致下游同步时

环境信息

canal version 1.1.3 mysql version 5.7

问题描述

{ "data": [], "database": "XXX", "es": 1577088014000, "id": 1233420, "isDdl": false, "mysqlType": { "ID": "BIGINT", "COMPANY_ID": "BIGINT", "PUNISH_OBJECT_ID": "BIGINT", "PUNISH_OBJECT": "VARCHAR(200)", "PUNISH_OBJECT_TYPE": "DOUBLE", "RELATION": "VARCHAR(200)", "TITLE": "VARCHAR(1500)", "CONTENT": "LONGTEXT", "NOTICE_DT": "DATETIME", "CASE_CATEGORY": "VARCHAR(60)", "NOTICE_WEBSITE": "VARCHAR(255)", "DECISION_DT": "DATETIME", "DECISION_GOV_ID": "BIGINT", "DECISION_GOV": "VARCHAR(300)", "REF_NUMBER": "VARCHAR(255)", "PUNISH_TYPE": "VARCHAR(1000)", "PENALTY_BASIS": "LONGTEXT", "PENALTY_REASON": "LONGTEXT", "PENALTY_RESULT": "LONGTEXT", "PUNISH_AMT": "DECIMAL(24,6)", "PENALTY_COMMENT": "LONGTEXT", "IS_DEL": "INTEGER", "CREATE_DT": "DATETIME(6)", "UPDT_DT": "DATETIME(6)" }, "old": null, "pkNames": ["ID"], "sql": "", "sqlType": { "ID": -5, "COMPANY_ID": -5, "PUNISH_OBJECT_ID": -5, "PUNISH_OBJECT": 12, "PUNISH_OBJECT_TYPE": 8, "RELATION": 12, "TITLE": 12, "CONTENT": 2005, "NOTICE_DT": 93, "CASE_CATEGORY": 12, "NOTICE_WEBSITE": 12, "DECISION_DT": 93, "DECISION_GOV_ID": -5, "DECISION_GOV": 12, "REF_NUMBER": 12, "PUNISH_TYPE": 12, "PENALTY_BASIS": 2005, "PENALTY_REASON": 2005, "PENALTY_RESULT": -4, "PUNISH_AMT": 3, "PENALTY_COMMENT": -4, "IS_DEL": 4, "CREATE_DT": 93, "UPDT_DT": 93 }, "table": "XXX", "ts": 1577088012412, "type": "INSERT" }

字段在mysql 中为 text 或 longtext类型, 但是canal解析对应的标准sql类型变成了LONGVARBINARY(-4),在canal-adapter解析时当作byte[] 来解析字段数据(实际上字段数据人String), 导致乱码

期待结果

mysql 中 text/longtext 对应为 clob类型 ,字段内容当作String处理

现执行情况

mysql 中 text/longtext 被解析为 LONGVARBINARY类型,字段内容被当作byte[] 来解析字段数据(实际上字段数据人String), 导致乱码

原提问者GitHub用户flackyang

展开
收起
Java工程师 2023-05-03 12:16:07 163 0
1 条回答
写回答
取消 提交回答
  • 可以看下example,有正确处理blob的例子

    原回答者GitHub用户agapple

    2023-05-04 15:50:53
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
神龙云服务器产品及技术深度解析 立即下载
弹性创造价值:基于ECS的最佳性价比实践解析 立即下载
又快又稳:阿里云下一代虚拟交换机解析 立即下载

相关镜像