Skip to content

Commit

Permalink
Update LogEventConvert.java (#4653)
Browse files Browse the repository at this point in the history
fixed issue #4652,  解决mysql中类型为MEDIUMTEXT的字段的javaType在不同场景的解析不一致的问题
  • Loading branch information
starrywu authored Mar 16, 2023
1 parent aada80b commit b52c5d1
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,23 @@ private boolean parseOneRow(RowData.Builder rowDataBuilder, RowsLogEvent event,
int javaType = buffer.getJavaType();
if (buffer.isNull()) {
columnBuilder.setIsNull(true);

// 处理各种类型
switch (javaType) {
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:

// https://github.com/alibaba/canal/issues/4652
// mysql binlog中blob/text都处理为blob类型,需要反查table
// meta,按编码解析text
if (fieldMeta != null && isText(fieldMeta.getColumnType())) {
javaType = Types.CLOB;
} else {
javaType = Types.BLOB;
}
break;
}
} else {
final Serializable value = buffer.getValue();
// 处理各种类型
Expand Down

0 comments on commit b52c5d1

Please sign in to comment.