Improve Second and Microsecond function
This commit is contained in:
@ -337,8 +337,9 @@ int ObExprMonthName::calc_result_type1(ObExprResType &type,
|
|||||||
type.set_collation_level(CS_LEVEL_IMPLICIT);
|
type.set_collation_level(CS_LEVEL_IMPLICIT);
|
||||||
|
|
||||||
common::ObObjTypeClass tc1 = ob_obj_type_class(type1.get_type());
|
common::ObObjTypeClass tc1 = ob_obj_type_class(type1.get_type());
|
||||||
if (ob_is_enumset_tc(type1.get_type())) {
|
if (common::ObEnumSetTC == tc1) {
|
||||||
type1.set_calc_type(common::ObVarcharType);
|
type1.set_calc_type(common::ObVarcharType);
|
||||||
|
type1.set_calc_collation_type(cs_type);
|
||||||
} else if ((common::ObFloatTC == tc1) || (common::ObDoubleTC == tc1)) {
|
} else if ((common::ObFloatTC == tc1) || (common::ObDoubleTC == tc1)) {
|
||||||
type1.set_calc_type(common::ObIntType);
|
type1.set_calc_type(common::ObIntType);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,14 +60,12 @@ inline int ObExprTimeBase::calc_result_type1(ObExprResType &type,
|
|||||||
ObExprResType &type1,
|
ObExprResType &type1,
|
||||||
common::ObExprTypeCtx &type_ctx) const
|
common::ObExprTypeCtx &type_ctx) const
|
||||||
{
|
{
|
||||||
UNUSED(type_ctx);
|
|
||||||
UNUSED(type1);
|
|
||||||
type.set_int32();
|
type.set_int32();
|
||||||
type.set_precision(4);
|
type.set_precision(4);
|
||||||
type.set_scale(0);
|
type.set_scale(0);
|
||||||
common::ObObjTypeClass tc1 = ob_obj_type_class(type1.get_type());
|
common::ObObjTypeClass tc1 = ob_obj_type_class(type1.get_type());
|
||||||
if (ob_is_enumset_tc(type1.get_type())) {
|
if (common::ObEnumSetTC == tc1) {
|
||||||
type1.set_calc_type(common::ObVarcharType);
|
type1.set_calc_type_default_varchar();
|
||||||
} else if ((common::ObFloatTC == tc1) || (common::ObDoubleTC == tc1)) {
|
} else if ((common::ObFloatTC == tc1) || (common::ObDoubleTC == tc1)) {
|
||||||
type1.set_calc_type(common::ObIntType);
|
type1.set_calc_type(common::ObIntType);
|
||||||
}
|
}
|
||||||
@ -102,22 +100,56 @@ public:
|
|||||||
ObExprSecond();
|
ObExprSecond();
|
||||||
explicit ObExprSecond(common::ObIAllocator &alloc);
|
explicit ObExprSecond(common::ObIAllocator &alloc);
|
||||||
virtual ~ObExprSecond();
|
virtual ~ObExprSecond();
|
||||||
|
virtual int calc_result_type1(ObExprResType &type,
|
||||||
|
ObExprResType &type1,
|
||||||
|
common::ObExprTypeCtx &type_ctx) const;
|
||||||
static int calc_second(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum);
|
static int calc_second(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum);
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObExprSecond);
|
DISALLOW_COPY_AND_ASSIGN(ObExprSecond);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline int ObExprSecond::calc_result_type1(ObExprResType &type,
|
||||||
|
ObExprResType &type1,
|
||||||
|
common::ObExprTypeCtx &type_ctx) const
|
||||||
|
{
|
||||||
|
type.set_int32();
|
||||||
|
type.set_precision(4);
|
||||||
|
type.set_scale(0);
|
||||||
|
common::ObObjTypeClass tc1 = ob_obj_type_class(type1.get_type());
|
||||||
|
if ((common::ObEnumSetTC == tc1) || (common::ObFloatTC == tc1) || (common::ObDoubleTC == tc1)) {
|
||||||
|
type1.set_calc_type_default_varchar();
|
||||||
|
}
|
||||||
|
return common::OB_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
class ObExprMicrosecond: public ObExprTimeBase
|
class ObExprMicrosecond: public ObExprTimeBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ObExprMicrosecond();
|
ObExprMicrosecond();
|
||||||
explicit ObExprMicrosecond(common::ObIAllocator &alloc);
|
explicit ObExprMicrosecond(common::ObIAllocator &alloc);
|
||||||
virtual ~ObExprMicrosecond();
|
virtual ~ObExprMicrosecond();
|
||||||
|
virtual int calc_result_type1(ObExprResType &type,
|
||||||
|
ObExprResType &type1,
|
||||||
|
common::ObExprTypeCtx &type_ctx) const;
|
||||||
static int calc_microsecond(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum);
|
static int calc_microsecond(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum);
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObExprMicrosecond);
|
DISALLOW_COPY_AND_ASSIGN(ObExprMicrosecond);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline int ObExprMicrosecond::calc_result_type1(ObExprResType &type,
|
||||||
|
ObExprResType &type1,
|
||||||
|
common::ObExprTypeCtx &type_ctx) const
|
||||||
|
{
|
||||||
|
type.set_int32();
|
||||||
|
type.set_precision(4);
|
||||||
|
type.set_scale(0);
|
||||||
|
common::ObObjTypeClass tc1 = ob_obj_type_class(type1.get_type());
|
||||||
|
if ((common::ObEnumSetTC == tc1) || (common::ObFloatTC == tc1) || (common::ObDoubleTC == tc1)) {
|
||||||
|
type1.set_calc_type_default_varchar();
|
||||||
|
}
|
||||||
|
return common::OB_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
class ObExprYear: public ObExprTimeBase
|
class ObExprYear: public ObExprTimeBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user