[CP] fix core caused by missed core and cast interval to year failed error

This commit is contained in:
Larry955
2022-12-13 14:37:57 +00:00
committed by ob-robot
parent 2c1b2f160d
commit 80b8c6361d
2 changed files with 5 additions and 1 deletions

View File

@ -504,10 +504,13 @@ int ObExprCast::get_cast_type(const ObExprResType param_type2,
dst_type.set_collation_type(CS_TYPE_UTF8MB4_BIN);
} else if (ob_is_interval_tc(obj_type)) {
if (CM_IS_EXPLICIT_CAST(cast_mode) &&
(!ObIntervalScaleUtil::scale_check(parse_node.int16_values_[OB_NODE_CAST_N_PREC_IDX]) ||
((ObIntervalYMType != obj_type && !ObIntervalScaleUtil::scale_check(parse_node.int16_values_[OB_NODE_CAST_N_PREC_IDX])) ||
!ObIntervalScaleUtil::scale_check(parse_node.int16_values_[OB_NODE_CAST_N_SCALE_IDX]))) {
ret = OB_ERR_DATETIME_INTERVAL_PRECISION_OUT_OF_RANGE;
LOG_WARN("target interval type precision out of range", K(ret), K(obj_type));
} else if (ObIntervalYMType == obj_type) {
// interval year to month type has no precision
dst_type.set_scale(parse_node.int16_values_[OB_NODE_CAST_N_SCALE_IDX]);
} else if (ob_is_interval_ds(obj_type)) {
//scale in day seconds type is day_scale * 10 + seconds_scale.
dst_type.set_scale(parse_node.int16_values_[OB_NODE_CAST_N_PREC_IDX] * 10 +

View File

@ -6574,6 +6574,7 @@ int ObRawExprUtils::create_real_cast_expr(ObRawExprFactory &expr_factory,
int ret = OB_SUCCESS;
ObConstRawExpr *dst_expr = NULL;
ParseNode parse_node;
memset(&parse_node, 0, sizeof(ParseNode));
ObObj val;
if (OB_ISNULL(src_expr) || OB_ISNULL(session_info)) {