提交 fbdf9545 编写于 作者: O obdev 提交者: wangzelin.wzl

BUGFIX:Abnormal change of json integer value.

上级 39e1f2e9
...@@ -945,8 +945,9 @@ int ObJsonBin::to_tree(ObJsonNode *&json_tree) ...@@ -945,8 +945,9 @@ int ObJsonBin::to_tree(ObJsonNode *&json_tree)
} else { } else {
// inline value store all store in union // inline value store all store in union
offset = OB_JSON_TYPE_IS_INLINE(type) ? uint_val_ : offset; offset = OB_JSON_TYPE_IS_INLINE(type) ? uint_val_ : offset;
type = ObJsonVar::get_var_type(offset);
} }
if (OB_FAIL(deserialize_json_value(ptr + offset, curr_.length() - offset, type_, offset, json_tree))) { if (OB_FAIL(deserialize_json_value(ptr + offset, curr_.length() - offset, type_, offset, json_tree, type))) {
LOG_WARN("deserialize failed", K(ret), K(offset), K(type)); LOG_WARN("deserialize failed", K(ret), K(offset), K(type));
} }
} }
...@@ -958,7 +959,8 @@ int ObJsonBin::deserialize_json_value(const char *data, ...@@ -958,7 +959,8 @@ int ObJsonBin::deserialize_json_value(const char *data,
uint64_t length, uint64_t length,
uint8_t type, uint8_t type,
uint64_t value_offset, uint64_t value_offset,
ObJsonNode *&json_tree) ObJsonNode *&json_tree,
uint64_t type_size)
{ {
INIT_SUCC(ret); INIT_SUCC(ret);
bool is_inlined = OB_JSON_TYPE_IS_INLINE(type); bool is_inlined = OB_JSON_TYPE_IS_INLINE(type);
...@@ -1006,7 +1008,7 @@ int ObJsonBin::deserialize_json_value(const char *data, ...@@ -1006,7 +1008,7 @@ int ObJsonBin::deserialize_json_value(const char *data,
LOG_WARN("fail to alloc memory for int json node", K(ret)); LOG_WARN("fail to alloc memory for int json node", K(ret));
} else { } else {
if (is_inlined) { if (is_inlined) {
ObJsonInt *node = new(buf)ObJsonInt(ObJsonVar::var_uint2int(value_offset)); ObJsonInt *node = new(buf)ObJsonInt(ObJsonVar::var_uint2int(value_offset, type_size));
json_tree = static_cast<ObJsonNode*>(node); json_tree = static_cast<ObJsonNode*>(node);
} else { } else {
int64_t val = 0; int64_t val = 0;
...@@ -1329,7 +1331,7 @@ int ObJsonBin::deserialize_json_object_v0(const char *data, uint64_t length, ObJ ...@@ -1329,7 +1331,7 @@ int ObJsonBin::deserialize_json_object_v0(const char *data, uint64_t length, ObJ
ObString key(key_len, reinterpret_cast<const char*>(key_buf)); ObString key(key_len, reinterpret_cast<const char*>(key_buf));
const char *val = data + value_offset; const char *val = data + value_offset;
ObJsonNode *node = NULL; ObJsonNode *node = NULL;
ret = deserialize_json_value(val, length - value_offset, val_type, value_offset, node); ret = deserialize_json_value(val, length - value_offset, val_type, value_offset, node, type);
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
if (OB_FAIL(object->add(key, node))) { if (OB_FAIL(object->add(key, node))) {
LOG_WARN("failed to add node to obj", K(ret)); LOG_WARN("failed to add node to obj", K(ret));
...@@ -1392,8 +1394,8 @@ int ObJsonBin::deserialize_json_array_v0(const char *data, uint64_t length, ObJs ...@@ -1392,8 +1394,8 @@ int ObJsonBin::deserialize_json_array_v0(const char *data, uint64_t length, ObJs
} else { } else {
const char *val = data + val_offset; const char *val = data + val_offset;
ObJsonNode *node = NULL; ObJsonNode *node = NULL;
if (OB_FAIL(deserialize_json_value(val, length - val_offset, val_type, val_offset, node))) { if (OB_FAIL(deserialize_json_value(val, length - val_offset, val_type, val_offset, node, type))) {
LOG_WARN("failed to deserialize child node", K(ret), K(i), K(val_type), K(val_offset)); LOG_WARN("failed to deserialize child node", K(ret), K(i), K(val_type), K(val_offset), K(type));
} else if (OB_FAIL(array->append(node))) { } else if (OB_FAIL(array->append(node))) {
LOG_WARN("failed to append node to array", K(ret)); LOG_WARN("failed to append node to array", K(ret));
} }
...@@ -4346,7 +4348,7 @@ uint64_t ObJsonVar::var_int2uint(int64_t var) ...@@ -4346,7 +4348,7 @@ uint64_t ObJsonVar::var_int2uint(int64_t var)
int64_t ObJsonVar::var_uint2int(uint64_t var, uint8_t entry_size) int64_t ObJsonVar::var_uint2int(uint64_t var, uint8_t entry_size)
{ {
ObJsonBinLenSize size = static_cast<ObJsonBinLenSize>(max(ObJsonVar::get_var_type(var), entry_size)); ObJsonBinLenSize size = static_cast<ObJsonBinLenSize>(entry_size);
int64_t val = 0; int64_t val = 0;
switch (size) { switch (size) {
case JBLS_UINT8: { case JBLS_UINT8: {
......
...@@ -412,7 +412,8 @@ private: ...@@ -412,7 +412,8 @@ private:
uint64_t length, uint64_t length,
uint8_t type, uint8_t type,
uint64_t value_offset, uint64_t value_offset,
ObJsonNode *&json_tree); ObJsonNode *&json_tree,
uint64_t type_size);
int deserialize_json_object_v0(const char *data, uint64_t length, ObJsonObject *object); int deserialize_json_object_v0(const char *data, uint64_t length, ObJsonObject *object);
inline int deserialize_json_object(const char *data, uint64_t length, ObJsonObject *object, ObJBVerType vertype); inline int deserialize_json_object(const char *data, uint64_t length, ObJsonObject *object, ObJBVerType vertype);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册