19
19
20
20
/**
21
21
* Extracting JDBC type & value information from packed rows-buffer.
22
- *
22
+ *
23
23
* @see mysql-5.1.60/sql/log_event.cc - Rows_log_event::print_verbose_one_row
24
24
* @author <a href="mailto:[email protected] ">Changyuan.lh</a>
25
25
* @version 1.0
@@ -70,7 +70,7 @@ public final boolean nextOneRow(BitSet columns) {
70
70
71
71
/**
72
72
* Extracting next row from packed buffer.
73
- *
73
+ *
74
74
* @see mysql-5.1.60/sql/log_event.cc -
75
75
* Rows_log_event::print_verbose_one_row
76
76
*/
@@ -104,7 +104,7 @@ public final boolean nextOneRow(BitSet columns, boolean after) {
104
104
105
105
/**
106
106
* Extracting next field value from packed buffer.
107
- *
107
+ *
108
108
* @see mysql-5.1.60/sql/log_event.cc -
109
109
* Rows_log_event::print_verbose_one_row
110
110
*/
@@ -114,7 +114,7 @@ public final Serializable nextValue(final String columName, final int columnInde
114
114
115
115
/**
116
116
* Extracting next field value from packed buffer.
117
- *
117
+ *
118
118
* @see mysql-5.1.60/sql/log_event.cc -
119
119
* Rows_log_event::print_verbose_one_row
120
120
*/
@@ -277,7 +277,7 @@ static int mysqlToJavaType(int type, final int meta, boolean isBinary) {
277
277
278
278
/**
279
279
* Extracting next field value from packed buffer.
280
- *
280
+ *
281
281
* @see mysql-5.1.60/sql/log_event.cc - log_event_print_value
282
282
*/
283
283
final Serializable fetchValue (String columnName , int columnIndex , int type , final int meta , boolean isBinary ) {
@@ -1077,30 +1077,21 @@ final Serializable fetchValue(String columnName, int columnIndex, int type, fina
1077
1077
if (partialBits .get (1 )) {
1078
1078
// print_json_diff
1079
1079
int position = buffer .position ();
1080
- StringBuilder builder = JsonDiffConversion .print_json_diff (buffer ,
1081
- len ,
1082
- columnName ,
1083
- columnIndex ,
1084
- charset );
1085
- value = builder .toString ();
1086
- buffer .position (position + len );
1087
- } else {
1088
- if (0 == len ) {
1089
- // fixed issue #1 by lava, json column of zero length
1090
- // has no
1091
- // value, value parsing should be skipped
1092
- value = "" ;
1093
- } else {
1094
- int position = buffer .position ();
1095
- Json_Value jsonValue = JsonConversion .parse_value (buffer .getUint8 (),
1096
- buffer ,
1097
- len - 1 ,
1080
+ try {
1081
+ StringBuilder builder = JsonDiffConversion .print_json_diff (buffer ,
1082
+ len ,
1083
+ columnName ,
1084
+ columnIndex ,
1098
1085
charset );
1099
- StringBuilder builder = new StringBuilder ();
1100
- jsonValue .toJsonString (builder , charset );
1101
1086
value = builder .toString ();
1102
1087
buffer .position (position + len );
1088
+ } catch (IllegalArgumentException e ) {
1089
+ buffer .position (position );
1090
+ // print_json_diff failed, fallback to parse_value
1091
+ parseJsonFromFullValue (len );
1103
1092
}
1093
+ } else {
1094
+ parseJsonFromFullValue (len );
1104
1095
}
1105
1096
javaType = Types .VARCHAR ;
1106
1097
length = len ;
@@ -1155,6 +1146,25 @@ final Serializable fetchValue(String columnName, int columnIndex, int type, fina
1155
1146
return value ;
1156
1147
}
1157
1148
1149
+ private void parseJsonFromFullValue (int len ) {
1150
+ if (0 == len ) {
1151
+ // fixed issue #1 by lava, json column of zero length
1152
+ // has no
1153
+ // value, value parsing should be skipped
1154
+ value = "" ;
1155
+ } else {
1156
+ int position = buffer .position ();
1157
+ Json_Value jsonValue = JsonConversion .parse_value (buffer .getUint8 (),
1158
+ buffer ,
1159
+ len - 1 ,
1160
+ charset );
1161
+ StringBuilder builder = new StringBuilder ();
1162
+ jsonValue .toJsonString (builder , charset );
1163
+ value = builder .toString ();
1164
+ buffer .position (position + len );
1165
+ }
1166
+ }
1167
+
1158
1168
public final boolean isNull () {
1159
1169
return fNull ;
1160
1170
}
0 commit comments