From c856bc403ed82efcafabb97d8443d2d50b2d9f66 Mon Sep 17 00:00:00 2001 From: xj0 Date: Mon, 28 Feb 2022 20:16:09 +0800 Subject: [PATCH] [fix] json not strict mode insert --- deps/oblib/src/common/object/ob_obj_funcs.h | 4 +++- deps/oblib/src/rpc/obmysql/ob_mysql_util.cpp | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/deps/oblib/src/common/object/ob_obj_funcs.h b/deps/oblib/src/common/object/ob_obj_funcs.h index ae0e95fc61..c357825f64 100644 --- a/deps/oblib/src/common/object/ob_obj_funcs.h +++ b/deps/oblib/src/common/object/ob_obj_funcs.h @@ -1423,7 +1423,9 @@ DEF_TEXT_FUNCS(ObLongTextType, string, ObString); uint64_t hash_res = 0; \ ObJsonBin j_bin(j_bin_str.ptr(), j_bin_str.length()); \ ObIJsonBase *j_base = &j_bin; \ - if (OB_FAIL(j_bin.reset_iter())) { \ + if (j_bin_str.length() ==0 || param.is_null()) { \ + hash_res = hash; \ + } else if (OB_FAIL(j_bin.reset_iter())) { \ COMMON_LOG(WARN, "fail to reset json bin iter", K(ret), K(j_bin_str)); \ right_to_die_or_duty_to_live(); \ } else if (OB_FAIL(j_base->calc_json_hash_value(hash, T::hash, hash_res))) { \ diff --git a/deps/oblib/src/rpc/obmysql/ob_mysql_util.cpp b/deps/oblib/src/rpc/obmysql/ob_mysql_util.cpp index dc6ef3fbd2..5b3cdd1891 100644 --- a/deps/oblib/src/rpc/obmysql/ob_mysql_util.cpp +++ b/deps/oblib/src/rpc/obmysql/ob_mysql_util.cpp @@ -996,6 +996,10 @@ int ObMySQLUtil::json_cell_str(char *buf, const int64_t len, const ObString &val if (OB_ISNULL(buf)) { ret = OB_INVALID_ARGUMENT; OB_LOG(WARN, "invalid input args", K(ret), KP(buf)); + } else if (val.length() == 0) { + if (OB_FAIL(ObMySQLUtil::store_null(buf, len, pos))) { + OB_LOG(WARN, "fail to set null string", K(pos), K(len)); + } } else if (OB_FAIL(j_bin.reset_iter())) { OB_LOG(WARN, "fail to reset json bin iter", K(ret), K(val)); } else if (OB_FAIL(j_base->print(jbuf, true))) {