pingcap/tidb
View on GitHubRefactor currentTimeFunctionClass and utcTimeFunctionClass
Open
#27,760 opened on Sep 2, 2021
help wantedtype/enhancement
Description
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.