Improve Second and Microsecond function
This commit is contained in:
parent
1889cad1a3
commit
4bdf785213
@ -337,8 +337,9 @@ int ObExprMonthName::calc_result_type1(ObExprResType &type,
|
||||
type.set_collation_level(CS_LEVEL_IMPLICIT);
|
||||
|
||||
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_collation_type(cs_type);
|
||||
} else if ((common::ObFloatTC == tc1) || (common::ObDoubleTC == tc1)) {
|
||||
type1.set_calc_type(common::ObIntType);
|
||||
}
|
||||
|
@ -60,14 +60,12 @@ inline int ObExprTimeBase::calc_result_type1(ObExprResType &type,
|
||||
ObExprResType &type1,
|
||||
common::ObExprTypeCtx &type_ctx) const
|
||||
{
|
||||
UNUSED(type_ctx);
|
||||
UNUSED(type1);
|
||||
type.set_int32();
|
||||
type.set_precision(4);
|
||||
type.set_scale(0);
|
||||
common::ObObjTypeClass tc1 = ob_obj_type_class(type1.get_type());
|
||||
if (ob_is_enumset_tc(type1.get_type())) {
|
||||
type1.set_calc_type(common::ObVarcharType);
|
||||
if (common::ObEnumSetTC == tc1) {
|
||||
type1.set_calc_type_default_varchar();
|
||||
} else if ((common::ObFloatTC == tc1) || (common::ObDoubleTC == tc1)) {
|
||||
type1.set_calc_type(common::ObIntType);
|
||||
}
|
||||
@ -102,22 +100,56 @@ public:
|
||||
ObExprSecond();
|
||||
explicit ObExprSecond(common::ObIAllocator &alloc);
|
||||
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);
|
||||
private:
|
||||
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
|
||||
{
|
||||
public:
|
||||
ObExprMicrosecond();
|
||||
explicit ObExprMicrosecond(common::ObIAllocator &alloc);
|
||||
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);
|
||||
private:
|
||||
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
|
||||
{
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user