diff --git a/src/sql/engine/expr/ob_expr_cast.cpp b/src/sql/engine/expr/ob_expr_cast.cpp index 9d7296419f..947a7b8ec2 100644 --- a/src/sql/engine/expr/ob_expr_cast.cpp +++ b/src/sql/engine/expr/ob_expr_cast.cpp @@ -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 + diff --git a/src/sql/resolver/expr/ob_raw_expr_util.cpp b/src/sql/resolver/expr/ob_raw_expr_util.cpp index f20a5b1804..5a81d7c0a8 100644 --- a/src/sql/resolver/expr/ob_raw_expr_util.cpp +++ b/src/sql/resolver/expr/ob_raw_expr_util.cpp @@ -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)) {