[GIS] fix expr coredump

This commit is contained in:
obdev
2024-04-11 09:46:22 +00:00
committed by ob-robot
parent 5cc0e4fc46
commit 42e39c6f92
6 changed files with 26 additions and 12 deletions

View File

@ -152,11 +152,11 @@ int ObExprGeomWkb::eval_geom_wkb(const ObExpr &expr,
axis_order))) {
LOG_WARN("fail to parse axis order option string", K(ret), K(option_str));
ret = OB_ERR_INVALID_OPTION_KEY_VALUE_PAIR; // adapt mysql errcode.
const uint64_t STR_LEN_MAX = 512;
char err_str[STR_LEN_MAX] = {0};
const int64_t len = option_str.length();
char str[len + 1];
str[len] = '\0';
MEMCPY(str, option_str.ptr(), len);
LOG_USER_ERROR(OB_ERR_INVALID_OPTION_KEY_VALUE_PAIR, str, '=', get_func_name());
MEMCPY(err_str, option_str.ptr(), (len >= STR_LEN_MAX ? (STR_LEN_MAX - 1) : len));
LOG_USER_ERROR(OB_ERR_INVALID_OPTION_KEY_VALUE_PAIR, err_str, '=', get_func_name());
} else if (OB_FAIL(ObGeoExprUtils::check_need_reverse(axis_order, need_reverse))) {
LOG_WARN("fail to check need reverse", K(ret), K(axis_order));
}

View File

@ -64,14 +64,15 @@ int ObExprSTSRID::calc_result_typeN(ObExprResType& type,
} else if (!ob_is_geometry(types_stack[0].get_type()) && !ob_is_string_type(types_stack[0].get_type())) {
ret = OB_ERR_GIS_INVALID_DATA;
LOG_USER_ERROR(OB_ERR_GIS_INVALID_DATA, get_name());
} else {
type.set_int32();
}
if (OB_SUCC(ret) && param_num > 1) {
types_stack[1].set_calc_type(ObIntType);
type_ctx.set_cast_mode(type_ctx.get_cast_mode() | CM_STRING_INTEGER_TRUNC);
type.set_geometry();
type.set_length((ObAccuracy::DDL_DEFAULT_ACCURACY[ObGeometryType]).get_length());
if (OB_SUCC(ret)) {
type.set_int32();
if (param_num > 1) {
types_stack[1].set_calc_type(ObIntType);
type_ctx.set_cast_mode(type_ctx.get_cast_mode() | CM_STRING_INTEGER_TRUNC);
type.set_geometry();
type.set_length((ObAccuracy::DDL_DEFAULT_ACCURACY[ObGeometryType]).get_length());
}
}
}