@@ -14,7 +14,7 @@ func (t *testSyncerSuite) TestIndexOutOfRange(c *C) {
1414ServerVersion : []uint8 {0x35 , 0x2e , 0x36 , 0x2e , 0x32 , 0x30 , 0x2d , 0x6c , 0x6f , 0x67 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 },
1515CreateTimestamp : 0x0 ,
1616EventHeaderLength : 0x13 ,
17- EventTypeHeaderLengths : []uint8 {0x38 , 0xd , 0x0 , 0x8 , 0x0 , 0x12 , 0x0 , 0x4 , 0x4 , 0x4 , 0x4 , 0x12 , 0x0 , 0x0 , 0x5c , 0x0 , 0x4 , 0x1a , 0x8 , 0x0 , 0x0 , 0x0 , 0x8 , 0x8 , 0x8 , 0x2 , 0x0 , 0x0 , 0x0 , 0xa , 0xa , 0xa , 0x19 , 0x19 , 0x0 },
17+ EventTypeHeaderLengths : []uint8 {0x38 , 0xd , 0x0 , 0x8 , 0x0 , 0x12 , 0x0 , 0x4 , 0x4 , 0x4 , 0x4 , 0x12 , 0x0 , 0x0 , 0x5c , 0x0 , 0x4 , 0x1a , 0x8 , 0x0 , 0x0 , 0x0 , 0x8 , 0x8 , 0x8 , 0x2 , 0x0 , 0x0 , 0x0 , 0xa , 0xa , 0xa , 0x19 , 0x19 , 0x0 , 0x12 , 0x34 , 0x0 , 0xa , 0x28 , 0x0 },
1818ChecksumAlgorithm : 0x1 ,
1919}
2020
@@ -50,7 +50,7 @@ func (t *testSyncerSuite) TestParseEvent(c *C) {
5050ServerVersion : []uint8 {0x35 , 0x2e , 0x36 , 0x2e , 0x32 , 0x30 , 0x2d , 0x6c , 0x6f , 0x67 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 },
5151CreateTimestamp : 0x0 ,
5252EventHeaderLength : 0x13 ,
53- EventTypeHeaderLengths : []uint8 {0x38 , 0xd , 0x0 , 0x8 , 0x0 , 0x12 , 0x0 , 0x4 , 0x4 , 0x4 , 0x4 , 0x12 , 0x0 , 0x0 , 0x5c , 0x0 , 0x4 , 0x1a , 0x8 , 0x0 , 0x0 , 0x0 , 0x8 , 0x8 , 0x8 , 0x2 , 0x0 , 0x0 , 0x0 , 0xa , 0xa , 0xa , 0x19 , 0x19 , 0x0 },
53+ EventTypeHeaderLengths : []uint8 {0x38 , 0xd , 0x0 , 0x8 , 0x0 , 0x12 , 0x0 , 0x4 , 0x4 , 0x4 , 0x4 , 0x12 , 0x0 , 0x0 , 0x5c , 0x0 , 0x4 , 0x1a , 0x8 , 0x0 , 0x0 , 0x0 , 0x8 , 0x8 , 0x8 , 0x2 , 0x0 , 0x0 , 0x0 , 0xa , 0xa , 0xa , 0x19 , 0x19 , 0x0 , 0x12 , 0x34 , 0x0 , 0xa , 0x28 , 0x0 },
5454ChecksumAlgorithm : 0x0 ,
5555}
5656testCases := []struct {
@@ -108,3 +108,34 @@ func (t *testSyncerSuite) TestRowsEventDecodeFunc(c *C) {
108108c .Assert (e .Header .EventSize , Equals , tc .eventSize )
109109}
110110}
111+
112+ func (t * testSyncerSuite ) TestRowsEventDecodeImageWithEmptyJSON (c * C ) {
113+ data := []byte ("\x01 \a \x00 \xf6 +\x0f \x00 \xeb \xaf P\x02 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x99 \xac \xfa \xbe Ù\xaf \xab 1\x18 4\x11 \x00 \x00 " )
114+
115+ bitmap := []byte {255 }
116+
117+ table := TableMapEvent {
118+ ColumnType : []byte {3 , 3 , 245 , 245 , 245 , 18 , 18 , 3 },
119+ ColumnMeta : []uint16 {0 , 0 , 4 , 4 , 4 , 0 , 0 , 0 },
120+ }
121+
122+ e := RowsEvent {
123+ eventType : PARTIAL_UPDATE_ROWS_EVENT ,
124+ Table : & table ,
125+ ColumnCount : uint64 (len (table .ColumnType )),
126+ }
127+ n , err := e .decodeImage (data , bitmap , EnumRowImageTypeUpdateAI )
128+ c .Assert (err , IsNil )
129+ c .Assert (n , Equals , len (data ))
130+
131+ c .Assert (len (e .Rows ), Equals , 1 )
132+ c .Assert (len (e .Rows [0 ]), Equals , len (table .ColumnType ))
133+
134+ row := e .Rows [0 ]
135+ c .Assert (row [0 ], Equals , int32 (994294 ))
136+ c .Assert (row [1 ], Equals , int32 (38842347 ))
137+ c .Assert (row [2 ], DeepEquals , []byte {}) // empty json
138+ c .Assert (row [3 ], DeepEquals , []byte {}) // empty json
139+ c .Assert (row [4 ], DeepEquals , []byte {}) // empty json
140+ c .Assert (row [7 ], Equals , int32 (4404 ))
141+ }
0 commit comments