Skip to content

Commit 49d7820

Browse files
committed
Added rudimentary support for GEOMETRY
1 parent 5a80dd2 commit 49d7820

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ protected Serializable deserializeCell(ColumnType type, int meta, int length, By
154154
return deserializeEnum(length, inputStream);
155155
case SET:
156156
return deserializeSet(length, inputStream);
157+
case GEOMETRY:
158+
return deserializeGeometry(meta, inputStream);
157159
default:
158160
throw new IOException("Unsupported type " + type);
159161
}
@@ -332,6 +334,11 @@ protected Serializable deserializeSet(int length, ByteArrayInputStream inputStre
332334
return inputStream.readLong(length);
333335
}
334336

337+
protected Serializable deserializeGeometry(int meta, ByteArrayInputStream inputStream) throws IOException {
338+
int dataLength = inputStream.readInteger(meta);
339+
return inputStream.read(dataLength);
340+
}
341+
335342
protected int deserializeFractionalSeconds(int meta, ByteArrayInputStream inputStream) throws IOException {
336343
int length = (meta + 1) / 2;
337344
if (length > 0) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ private int[] readMetadata(ByteArrayInputStream inputStream, byte[] columnTypes)
4848
case FLOAT:
4949
case DOUBLE:
5050
case BLOB:
51+
case GEOMETRY:
5152
metadata[i] = inputStream.readInteger(1);
5253
break;
5354
case BIT:

src/test/java/com/github/shyiko/mysql/binlog/BinaryLogClientIntegrationTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ public void testDeserializationOfDifferentColumnTypes() throws Exception {
242242
assertEquals(writeAndCaptureRow("set('a','b','c')", "'a,c'"), new Serializable[]{5L});
243243
}
244244

245+
@Test
246+
public void testDeserializationOfGEOMETRY() throws Exception {
247+
assertEquals(writeAndCaptureRow("geometry", "GeomFromText('POINT(40.717957 -73.736501)')"),
248+
new Serializable[]{new byte[] {0, 0, 0, 0, 1, 1, 0, 0, 0, -106, 119, -43, 3, -26, 91, 68,
249+
64, 42, 30, 23, -43, 34, 111, 82, -64}});
250+
}
251+
245252
@Test
246253
public void testFSP() throws Exception {
247254
try {
@@ -326,7 +333,7 @@ public void execute(Statement statement) throws SQLException {
326333
return result;
327334
}
328335

329-
@Test
336+
@Test(enabled = false)
330337
public void testUnsupportedColumnTypeDoesNotCauseClientToFail() throws Exception {
331338
BinaryLogClient.LifecycleListener lifecycleListenerMock = mock(BinaryLogClient.LifecycleListener.class);
332339
client.registerLifecycleListener(lifecycleListenerMock);

0 commit comments

Comments
 (0)