patch 4.0
This commit is contained in:
@ -15,47 +15,53 @@
|
||||
#include "lib/ob_name_def.h"
|
||||
#include "share/object/ob_obj_cast.h"
|
||||
#include "sql/engine/expr/ob_expr_operator.h"
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
class ObExprTimeStampDiff : public ObFuncExprOperator {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
class ObExprTimeStampDiff : public ObFuncExprOperator
|
||||
{
|
||||
public:
|
||||
explicit ObExprTimeStampDiff(common::ObIAllocator& alloc);
|
||||
explicit ObExprTimeStampDiff(common::ObIAllocator &alloc);
|
||||
virtual ~ObExprTimeStampDiff();
|
||||
virtual int calc_result_type3(ObExprResType& type, ObExprResType& unit, ObExprResType& left, ObExprResType& right,
|
||||
common::ObExprTypeCtx& type_ctx) const override;
|
||||
virtual int calc_result3(common::ObObj& result, const common::ObObj& unit, const common::ObObj& left,
|
||||
const common::ObObj& right, common::ObExprCtx& expr_ctx) const override;
|
||||
virtual common::ObCastMode get_cast_mode() const override
|
||||
{
|
||||
return CM_NULL_ON_WARN;
|
||||
}
|
||||
|
||||
static int eval_timestamp_diff(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& res);
|
||||
virtual int cg_expr(ObExprCGCtx& ctx, const ObRawExpr& raw_expr, ObExpr& rt_expr) const override;
|
||||
virtual int calc_result_type3(ObExprResType &type,
|
||||
ObExprResType &unit,
|
||||
ObExprResType &left,
|
||||
ObExprResType &right,
|
||||
common::ObExprTypeCtx &type_ctx) const;
|
||||
virtual common::ObCastMode get_cast_mode() const { return CM_NULL_ON_WARN;}
|
||||
|
||||
static int eval_timestamp_diff(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res);
|
||||
virtual int cg_expr(ObExprCGCtx &ctx, const ObRawExpr &raw_expr,
|
||||
ObExpr &rt_expr) const override;
|
||||
private:
|
||||
static int calc(int64_t& res, bool& is_null, int64_t unit_value, int64_t usec_left, int64_t usec_right,
|
||||
const common::ObTimeZoneInfo* tz_info);
|
||||
static int calc_month_diff(
|
||||
const int64_t& left, const int64_t& right, const common::ObTimeZoneInfo* tz_info, int64_t& diff);
|
||||
static int adjust_sub_one(const common::ObTime* p_min, const common::ObTime* p_max, int64_t& bias);
|
||||
static int calc(int64_t &res, bool &is_null, int64_t unit_value, int64_t usec_left,
|
||||
int64_t usec_right, const common::ObTimeZoneInfo *tz_info);
|
||||
static int calc_month_diff(const int64_t &left,
|
||||
const int64_t &right,
|
||||
const common::ObTimeZoneInfo *tz_info,
|
||||
int64_t &diff);
|
||||
static int adjust_sub_one(const common::ObTime *p_min, const common::ObTime *p_max, int64_t &bias);
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObExprTimeStampDiff);
|
||||
};
|
||||
|
||||
inline int ObExprTimeStampDiff::calc_result_type3(ObExprResType& type, ObExprResType& unit, ObExprResType& left,
|
||||
ObExprResType& right, common::ObExprTypeCtx& type_ctx) const
|
||||
inline int ObExprTimeStampDiff::calc_result_type3(ObExprResType &type,
|
||||
ObExprResType &unit,
|
||||
ObExprResType &left,
|
||||
ObExprResType &right,
|
||||
common::ObExprTypeCtx &type_ctx) const
|
||||
{
|
||||
UNUSED(type_ctx);
|
||||
UNUSED(unit);
|
||||
type.set_int();
|
||||
type.set_scale(common::DEFAULT_SCALE_FOR_INTEGER);
|
||||
type.set_precision(common::ObAccuracy::DDL_DEFAULT_ACCURACY[common::ObIntType].precision_);
|
||||
// set calc type
|
||||
//set calc type
|
||||
left.set_calc_type(common::ObTimestampType);
|
||||
right.set_calc_type(common::ObTimestampType);
|
||||
return common::OB_SUCCESS;
|
||||
}
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
#endif //_OCEANBASE_SQL_OB_EXPR_TIME_STMAP_DIFF_H_
|
||||
} //sql
|
||||
} //oceanbase
|
||||
#endif //_OCEANBASE_SQL_OB_EXPR_TIME_STMAP_DIFF_H_
|
||||
|
||||
Reference in New Issue
Block a user