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.

貢獻者指南