Skip to content

Commit d32cc21

Browse files
committed
Added support for MySQL JSON type
1 parent 75f0a45 commit d32cc21

File tree

8 files changed

+3817
-4
lines changed

8 files changed

+3817
-4
lines changed

src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/AbstractRowsEventDataDeserializer.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
*/
1616
package com.github.shyiko.mysql.binlog.event.deserialization;
1717

18-
import com.github.shyiko.mysql.binlog.event.EventData;
19-
import com.github.shyiko.mysql.binlog.event.TableMapEventData;
20-
import com.github.shyiko.mysql.binlog.io.ByteArrayInputStream;
21-
2218
import java.io.IOException;
2319
import java.io.Serializable;
2420
import java.math.BigDecimal;
@@ -27,6 +23,10 @@
2723
import java.util.Map;
2824
import java.util.TimeZone;
2925

26+
import com.github.shyiko.mysql.binlog.event.EventData;
27+
import com.github.shyiko.mysql.binlog.event.TableMapEventData;
28+
import com.github.shyiko.mysql.binlog.io.ByteArrayInputStream;
29+
3030
/**
3131
* Whole class is basically a mix of <a href="https://code.google.com/p/open-replicator">open-replicator</a>'s
3232
* AbstractRowEventParser and MySQLUtils. Main purpose here is to ease rows deserialization.<p>
@@ -170,6 +170,8 @@ protected Serializable deserializeCell(ColumnType type, int meta, int length, By
170170
return deserializeSet(length, inputStream);
171171
case GEOMETRY:
172172
return deserializeGeometry(meta, inputStream);
173+
case JSON:
174+
return deserializeJson(meta, inputStream);
173175
default:
174176
throw new IOException("Unsupported type " + type);
175177
}
@@ -329,6 +331,11 @@ protected byte[] deserializeGeometry(int meta, ByteArrayInputStream inputStream)
329331
return inputStream.read(dataLength);
330332
}
331333

334+
protected byte[] deserializeJson(int meta, ByteArrayInputStream inputStream) throws IOException {
335+
int blobLength = inputStream.readInteger(meta);
336+
return inputStream.read(blobLength);
337+
}
338+
332339
// checkstyle, please ignore ParameterNumber for the next line
333340
private static Long asUnixTime(int year, int month, int day, int hour, int minute, int second, int millis) {
334341
// https://dev.mysql.com/doc/refman/5.0/en/datetime.html

src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/ColumnType.java

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public enum ColumnType {
4545
TIMESTAMP_V2(17),
4646
DATETIME_V2(18),
4747
TIME_V2(19),
48+
JSON(245),
4849
NEWDECIMAL(246),
4950
ENUM(247),
5051
SET(248),

src/main/java/com/github/shyiko/mysql/binlog/json/Base64.java

+2,047
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)