pingcap/tidb

Refactor currentTimeFunctionClass and utcTimeFunctionClass

Open

#27.760 geöffnet am 2. Sept. 2021

Auf GitHub ansehen
 (6 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Go (6.186 Forks)batch import
help wantedtype/enhancement

Repository-Metriken

Stars
 (40.090 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 14T 4h) (346 gemergte PRs in 30 T)

Beschreibung

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.

Contributor Guide