This commit is contained in:
Neal Hu
2018-06-07 23:52:13 +08:00
parent b6967dc0dc
commit 187b98fbda

View File

@@ -634,11 +634,14 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar
// fixed issue // fixed issue
// https://github.com/alibaba/canal/issues/66,特殊处理binary/varbinary,不能做编码处理 // https://github.com/alibaba/canal/issues/66,特殊处理binary/varbinary,不能做编码处理
boolean isBinary = false; boolean isBinary = false;
boolean isSingleBit = false;
if (fieldMeta != null) { if (fieldMeta != null) {
if (StringUtils.containsIgnoreCase(fieldMeta.getColumnType(), "VARBINARY")) { if (StringUtils.containsIgnoreCase(fieldMeta.getColumnType(), "VARBINARY")) {
isBinary = true; isBinary = true;
} else if (StringUtils.containsIgnoreCase(fieldMeta.getColumnType(), "BINARY")) { } else if (StringUtils.containsIgnoreCase(fieldMeta.getColumnType(), "BINARY")) {
isBinary = true; isBinary = true;
} else if (StringUtils.containsIgnoreCase(fieldMeta.getColumnType(), "tinyint(1)")) {
isSingleBit = true;
} }
} }
buffer.nextValue(info.type, info.meta, isBinary); buffer.nextValue(info.type, info.meta, isBinary);
@@ -648,6 +651,9 @@ public class LogEventConvert extends AbstractCanalLifeCycle implements BinlogPar
} }
int javaType = buffer.getJavaType(); int javaType = buffer.getJavaType();
if (isSingleBit && javaType == Types.TINYINT) {
javaType = Types.BIT;
}
if (buffer.isNull()) { if (buffer.isNull()) {
columnBuilder.setIsNull(true); columnBuilder.setIsNull(true);
} else { } else {