Skip to content

Commit

Permalink
fixed #3976 , support LogEvent.MYSQL_TYPE_TYPED_ARRAY
Browse files Browse the repository at this point in the history
  • Loading branch information
agapple committed May 19, 2022
1 parent e41e903 commit a574b91
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ public abstract class LogEvent {
public static final int MYSQL_TYPE_TIMESTAMP2 = 17;
public static final int MYSQL_TYPE_DATETIME2 = 18;
public static final int MYSQL_TYPE_TIME2 = 19;
public static final int MYSQL_TYPE_TYPED_ARRAY = 20;
public static final int MYSQL_TYPE_INVALID = 243;
public static final int MYSQL_TYPE_BOOL = 244;
public static final int MYSQL_TYPE_JSON = 245;
public static final int MYSQL_TYPE_NEWDECIMAL = 246;
public static final int MYSQL_TYPE_ENUM = 247;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,8 @@ final Serializable fetchValue(String columnName, int columnIndex, int type, fina
length = len;
break;
}
case LogEvent.MYSQL_TYPE_BOOL :
case LogEvent.MYSQL_TYPE_INVALID :
default:
logger.error(String.format("!! Don't know how to handle column type=%d meta=%d (%04X)",
type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,13 @@ public static final class ColumnInfo {
public int geoType;
public boolean nullable;
public boolean visibility;
public boolean array;

@Override
public String toString() {
return "ColumnInfo [type=" + type + ", meta=" + meta + ", name=" + name + ", unsigned=" + unsigned
+ ", pk=" + pk + ", set_enum_values=" + set_enum_values + ", charset=" + charset + ", geoType="
+ geoType + ", nullable=" + nullable + "]";
@Override public String toString() {
return "ColumnInfo{" + "type=" + type + ", meta=" + meta + ", name='" + name + '\'' + ", unsigned="
+ unsigned + ", pk=" + pk + ", set_enum_values=" + set_enum_values + ", charset=" + charset
+ ", geoType=" + geoType + ", nullable=" + nullable + ", visibility=" + visibility + ", array="
+ array + '}';
}
}

Expand Down Expand Up @@ -544,19 +545,26 @@ public TableMapLogEvent(LogHeader header, LogBuffer buffer, FormatDescriptionLog
*/
private final void decodeFields(LogBuffer buffer, final int len) {
final int limit = buffer.limit();

buffer.limit(len + buffer.position());
for (int i = 0; i < columnCnt; i++) {
ColumnInfo info = columnInfo[i];

switch (info.type) {
int binlogType = info.type;
if (binlogType == MYSQL_TYPE_TYPED_ARRAY) {
binlogType = buffer.getUint8();
}

switch (binlogType) {
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_DOUBLE:
case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_GEOMETRY:
case MYSQL_TYPE_TIME2:
case MYSQL_TYPE_DATETIME2:
case MYSQL_TYPE_TIMESTAMP2:
case MYSQL_TYPE_JSON:
/*
* These types store a single byte.
Expand All @@ -565,14 +573,6 @@ private final void decodeFields(LogBuffer buffer, final int len) {
break;
case MYSQL_TYPE_SET:
case MYSQL_TYPE_ENUM:
/*
* log_event.h : MYSQL_TYPE_SET & MYSQL_TYPE_ENUM : This
* enumeration value is only used internally and cannot
* exist in a binlog.
*/
logger.warn("This enumeration value is only used internally "
+ "and cannot exist in a binlog: type=" + info.type);
break;
case MYSQL_TYPE_STRING: {
/*
* log_event.h : The first byte is always
Expand Down Expand Up @@ -600,12 +600,6 @@ private final void decodeFields(LogBuffer buffer, final int len) {
info.meta = x;
break;
}
case MYSQL_TYPE_TIME2:
case MYSQL_TYPE_DATETIME2:
case MYSQL_TYPE_TIMESTAMP2: {
info.meta = buffer.getUint8();
break;
}
default:
info.meta = 0;
break;
Expand Down

0 comments on commit a574b91

Please sign in to comment.