[CP] Json bugfix: json column length and create view with json

This commit is contained in:
obdev
2022-08-22 15:55:22 +08:00
committed by wangyunlai.wyl
parent 811b538750
commit 97badd0075
17 changed files with 26 additions and 5 deletions

View File

@ -51,6 +51,7 @@ int ObExprJsonArray::calc_result_typeN(ObExprResType& type,
} else {
// param_num >= 0
type.set_json();
type.set_length((ObAccuracy::DDL_DEFAULT_ACCURACY[ObJsonType]).get_length());
for (int64_t i = 0; i < param_num; i++) {
if (ob_is_string_type(types_stack[i].get_type())) {
if (types_stack[i].get_charset_type() != CHARSET_UTF8MB4) {

View File

@ -50,6 +50,7 @@ int ObExprJsonArrayAppend::calc_result_typeN(ObExprResType& type,
LOG_USER_ERROR(OB_ERR_PARAM_SIZE, name.length(), name.ptr());
} else {
type.set_json();
type.set_length((ObAccuracy::DDL_DEFAULT_ACCURACY[ObJsonType]).get_length());
if (OB_FAIL(ObJsonExprHelper::is_valid_for_json(types_stack, 0, N_JSON_ARRAY_APPEND))) {
LOG_WARN("wrong type for json doc.", K(ret), K(types_stack[0].get_type()));

View File

@ -48,6 +48,7 @@ int ObExprJsonArrayInsert::calc_result_typeN(ObExprResType& type, ObExprResType*
LOG_USER_ERROR(OB_ERR_PARAM_SIZE, name.length(), name.ptr());
} else {
type.set_json();
type.set_length((ObAccuracy::DDL_DEFAULT_ACCURACY[ObJsonType]).get_length());
if (OB_FAIL(ObJsonExprHelper::is_valid_for_json(types_stack, 0, N_JSON_ARRAY_INSERT))) {
LOG_WARN("wrong type for json doc.", K(ret), K(types_stack[0].get_type()));

View File

@ -74,11 +74,8 @@ int ObExprJsonExtract::calc_result_typeN(ObExprResType& type,
}
if (OB_SUCC(ret)) {
if (is_null_result) {
type.set_null();
} else {
type.set_json();
}
type.set_json();
type.set_length((ObAccuracy::DDL_DEFAULT_ACCURACY[ObJsonType]).get_length());
}
}
return ret;

View File

@ -51,6 +51,7 @@ int ObExprJsonInsert::calc_result_typeN(ObExprResType& type,
LOG_USER_ERROR(OB_ERR_PARAM_SIZE, name.length(), name.ptr());
} else {
type.set_json();
type.set_length((ObAccuracy::DDL_DEFAULT_ACCURACY[ObJsonType]).get_length());
if (OB_FAIL(ObJsonExprHelper::is_valid_for_json(types_stack, 0, N_JSON_INSERT))) {
LOG_WARN("wrong type for json doc.", K(ret), K(types_stack[0].get_type()));

View File

@ -44,6 +44,7 @@ int ObExprJsonKeys::calc_result_typeN(ObExprResType& type,
} else {
// set result to json
type.set_json();
type.set_length((ObAccuracy::DDL_DEFAULT_ACCURACY[ObJsonType]).get_length());
// set type of json_doc
if (OB_FAIL(ObJsonExprHelper::is_valid_for_json(types_stack, 0, N_JSON_KEYS))) {

View File

@ -44,6 +44,7 @@ int ObExprJsonMergePatch::calc_result_typeN(ObExprResType& type,
INIT_SUCC(ret);
type.set_json();
type.set_length((ObAccuracy::DDL_DEFAULT_ACCURACY[ObJsonType]).get_length());
for (int64_t i = 0; OB_SUCC(ret) && i < param_num; i++) {
if (OB_FAIL(ObJsonExprHelper::is_valid_for_json(types_stack, i, N_JSON_MERGE_PRESERVE))) {
LOG_WARN("wrong type for json doc.", K(ret), K(types_stack[i].get_type()));

View File

@ -53,6 +53,7 @@ int ObExprJsonMergePreserve::calc_result_typeN(ObExprResType& type,
UNUSED(type_ctx);
INIT_SUCC(ret);
type.set_json();
type.set_length((ObAccuracy::DDL_DEFAULT_ACCURACY[ObJsonType]).get_length());
bool is_result_null = false;
for (int64_t i = 0; OB_SUCC(ret) && !is_result_null && i < param_num; i++) {
if (types_stack[0].get_type() == ObNullType) {

View File

@ -45,6 +45,7 @@ int ObExprJsonObject::calc_result_typeN(ObExprResType& type,
LOG_USER_ERROR(OB_ERR_PARAM_SIZE, name.length(), name.ptr());
} else {
type.set_json();
type.set_length((ObAccuracy::DDL_DEFAULT_ACCURACY[ObJsonType]).get_length());
for (int64_t i = 0; OB_SUCC(ret) && i < param_num; i += 2) {
if ((types_stack[i].get_type() == ObNullType)) {
ret = OB_ERR_JSON_DOCUMENT_NULL_KEY;

View File

@ -49,6 +49,7 @@ int ObExprJsonRemove::calc_result_typeN(ObExprResType& type,
}
}
type.set_json();
type.set_length((ObAccuracy::DDL_DEFAULT_ACCURACY[ObJsonType]).get_length());
return ret;
}

View File

@ -55,6 +55,7 @@ int ObExprJsonReplace::calc_result_typeN(ObExprResType& type,
}
}
type.set_json();
type.set_length((ObAccuracy::DDL_DEFAULT_ACCURACY[ObJsonType]).get_length());
}
return ret;
}

View File

@ -218,6 +218,7 @@ int ObExprJsonSearch::calc_result_typeN(ObExprResType& type,
LOG_WARN("invalid param number", K(ret), K(param_num));
} else {
type.set_json();
type.set_length((ObAccuracy::DDL_DEFAULT_ACCURACY[ObJsonType]).get_length());
// json doc
if (OB_FAIL(ObJsonExprHelper::is_valid_for_json(types_stack, 0, "json_search"))) {

View File

@ -55,6 +55,7 @@ int ObExprJsonSet::calc_result_typeN(ObExprResType& type,
}
}
type.set_json();
type.set_length((ObAccuracy::DDL_DEFAULT_ACCURACY[ObJsonType]).get_length());
}
return ret;
}