fix lossless cast bug

This commit is contained in:
ChangerR
2024-02-09 21:57:47 +00:00
committed by ob-robot
parent 698822b5b3
commit 6f9754f7fe
2 changed files with 22 additions and 0 deletions

View File

@ -6193,6 +6193,22 @@ int ObOptimizerUtil::is_lossless_column_cast(const ObRawExpr *expr, bool &is_los
is_lossless = NUMBER_SCALE_UNKNOWN_YET == dst_type.get_scale()
&& PRECISION_UNKNOWN_YET == dst_type.get_precision();
}
} else if (ObCharType == child_type.get_type()) {
if (ObVarcharType == dst_type.get_type() && !expr->is_const_expr()) {
if ((dst_acc.get_length() >= child_type.get_accuracy().get_length() ||
dst_acc.get_length() == -1) &&
dst_type.get_obj_meta().get_collation_type() == child_type.get_obj_meta().get_collation_type()) {
is_lossless = true;
}
}
} else if (ObNCharType == child_type.get_type()) {
if (ObNVarchar2Type == dst_type.get_type() && !expr->is_const_expr()) {
if ((dst_acc.get_length() >= child_type.get_accuracy().get_length() ||
dst_acc.get_length() == -1) &&
dst_type.get_obj_meta().get_collation_type() == child_type.get_obj_meta().get_collation_type()) {
is_lossless = true;
}
}
}
}
LOG_DEBUG("lossless column cast", K(child_type), K(child_tc), K(dst_type), K(dst_tc),