Skip to content

Commit

Permalink
Update LogEventConvert.java (alibaba#4653)
Browse files Browse the repository at this point in the history
fixed issue alibaba#4652,  解决mysql中类型为MEDIUMTEXT的字段的javaType在不同场景的解析不一致的问题
  • Loading branch information
starrywu authored and zoemak committed Jan 30, 2024
1 parent 43a8c12 commit e1aecbb
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 e1aecbb

Please sign in to comment.