pingcap/tidb

Refactor currentTimeFunctionClass and utcTimeFunctionClass

Open

#27,760 创建于 2021年9月2日

在 GitHub 查看
 (6 评论) (0 反应) (0 负责人)Go (6,186 fork)batch import
help wantedtype/enhancement

仓库指标

Star
 (40,090 star)
PR 合并指标
 (平均合并 14天 4小时) (30 天内合并 346 个 PR)

描述

Enhancement

currentTimeFunctionClass is very simlier to currentTimeFunctionClass. We can see from the MySQL's code:

class Item_func_curtime_local final : public Item_func_curtime {
 protected:
  Time_zone *time_zone() override;

 public:
  Item_func_curtime_local(const POS &pos, uint8 dec_arg)
      : Item_func_curtime(pos, dec_arg) {}
  const char *func_name() const override { return "curtime"; }
};

class Item_func_curtime_utc final : public Item_func_curtime {
 protected:
  Time_zone *time_zone() override;

 public:
  Item_func_curtime_utc(const POS &pos, uint8 dec_arg)
      : Item_func_curtime(pos, dec_arg) {}
  const char *func_name() const override { return "utc_time"; }
};

This means that we can reuse some codes. After investigation, I found that utcTimeFunctionClass's flen is more accurate than currentTimeFunctionClass. We can fix it by using utcTimeFunctionClass's logic.

贡献者指南