pingcap/tidb

Refactor currentTimeFunctionClass and utcTimeFunctionClass

Open

#27,760 opened on 2021年9月2日

GitHub で見る
 (6 comments) (0 reactions) (0 assignees)Go (6,186 forks)batch import
help wantedtype/enhancement

Repository metrics

Stars
 (40,090 stars)
PR merge metrics
 (平均マージ 14d 4h) (30d で 346 merged PRs)

説明

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.

コントリビューターガイド