ob_expr_convert_tz.h 2.5 KB
Newer Older
A
Aristoeu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
/**
 * Copyright (c) 2021 OceanBase
 * OceanBase CE is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */

#ifndef OCEANBASE_SQL_OB_EXPR_CONVERT_TZ_H_
#define OCEANBASE_SQL_OB_EXPR_CONVERT_TZ_H_
#include "sql/engine/expr/ob_expr_operator.h"
namespace oceanbase
{
namespace sql
{
class ObExprConvertTZ : public ObFuncExprOperator{
public:
  explicit ObExprConvertTZ(common::ObIAllocator &alloc);
  virtual ~ObExprConvertTZ(){}
  virtual int calc_result_type3(ObExprResType &type,
                                ObExprResType &input1,
                                ObExprResType &input2,
                                ObExprResType &input3,
                                common::ObExprTypeCtx &type_ctx)const;
  virtual int calc_result3(common::ObObj &result,
                           const common::ObObj &input1,
                           const common::ObObj &input2,
                           const common::ObObj &input3,
                           common::ObExprCtx &expr_ctx) const;
  virtual int cg_expr(ObExprCGCtx &expr_cg_ctx, const ObRawExpr &raw_expr,
                      ObExpr &expr) const override;
  static int eval_convert_tz(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res);
  static int find_time_zone_pos(const ObString &tz_name,
                                        const ObTimeZoneInfo &tz_info,
O
obdev 已提交
39
                                        ObTimeZoneInfoPos &tz_info_pos);
S
st0 已提交
40 41
  template <typename T>
  static int calc_convert_tz(int64_t timestamp_data, const ObString &tz_str_s,//source time zone (input2)
A
Aristoeu 已提交
42
                        const ObString &tz_str_d,//destination time zone (input3)
S
st0 已提交
43 44 45 46 47 48 49
                        ObSQLSessionInfo *session,
                        T &result);
  static int calc(int64_t &timestamp_data, const ObTimeZoneInfoPos &tz_info_pos,
                 const bool input_utc_time);
  static int parse_string(int64_t &timestamp_data, const ObString &tz_str,
                          ObSQLSessionInfo *session, const bool input_utc_time);

A
Aristoeu 已提交
50 51 52 53 54 55 56 57 58 59
private:
  // disallow copy
  DISALLOW_COPY_AND_ASSIGN(ObExprConvertTZ);

};


} //sql
} //oceanbasel
#endif //OCEANBASE_SQL_OB_EXPR_CONVERT_TZ_H_