Skip to content

Commit

Permalink
coprocessor: extract a utility function 'is_unsigned' (tikv#5093)
Browse files Browse the repository at this point in the history
Signed-off-by: Lonng <heng@lonng.org>
  • Loading branch information
lonng authored and kennytm committed Jul 16, 2019
1 parent e65886c commit e2c7184
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/coprocessor/dag/rpn_expr/impl_cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,7 @@ pub fn get_cast_fn_rpn_node(
let to = box_try!(EvalType::try_from(to_field_type.tp()));
let func_meta = match (from, to) {
(EvalType::Int, EvalType::Decimal) => {
if !from_field_type
.as_accessor()
.flag()
.contains(FieldTypeFlag::UNSIGNED)
&& !to_field_type
.as_accessor()
.flag()
.contains(FieldTypeFlag::UNSIGNED)
{
if !is_unsigned(from_field_type) && !is_unsigned(&to_field_type) {
cast_int_as_decimal_fn_meta()
} else {
cast_uint_as_decimal_fn_meta()
Expand All @@ -55,6 +47,11 @@ pub fn get_cast_fn_rpn_node(
})
}

#[inline]
fn is_unsigned(ft: &FieldType) -> bool {
ft.as_accessor().flag().contains(FieldTypeFlag::UNSIGNED)
}

fn produce_dec_with_specified_tp(
ctx: &mut EvalContext,
dec: Decimal,
Expand Down

0 comments on commit e2c7184

Please sign in to comment.