diff options
author | Monty <monty@mariadb.org> | 2020-07-14 18:36:05 +0300 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-05-19 22:27:27 +0200 |
commit | aee84453ab6befef296afdf8e66a8e295b624c72 (patch) | |
tree | 8af9ab2b4062276ac060087c9fdfc39cee82ab50 /sql/item.h | |
parent | 78a0fe792aeebe00b79fe4f07afe584377b180ed (diff) | |
download | mariadb-git-aee84453ab6befef296afdf8e66a8e295b624c72.tar.gz |
MDEV-23001 Precreate static Item_bool() to simplify code
The following changes where done:
- Create global Item: Item_false and Item_true
- Replace all creation if 'FALSE' and 'TRUE' top level items used for
WHERE/HAVING/ON clauses to use Item_false and Item_true.
The benefit are:
- Less and faster code
- No test needed if we where able to create the new item.
- Fixed possible errors if 'new' would have failed for the Item_bool's
fixup! 470277728d2e27fe057cf33a437a9e40e1a04b61
Diffstat (limited to 'sql/item.h')
-rw-r--r-- | sql/item.h | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/sql/item.h b/sql/item.h index 1efd1ae8065..061cc9f2e90 100644 --- a/sql/item.h +++ b/sql/item.h @@ -963,6 +963,7 @@ public: optimisation changes in prepared statements */ Item(THD *thd, Item *item); + Item(); /* For const item */ virtual ~Item() { #ifdef EXTRA_DEBUG @@ -1986,7 +1987,7 @@ public: virtual bool limit_index_condition_pushdown_processor(void *arg) { return 0; } virtual bool exists2in_processor(void *arg) { return 0; } virtual bool find_selective_predicates_list_processor(void *arg) { return 0; } - bool cleanup_is_expensive_cache_processor(void *arg) + virtual bool cleanup_is_expensive_cache_processor(void *arg) { is_expensive_cache= (int8)(-1); return 0; @@ -2837,6 +2838,7 @@ protected: fix_charset_and_length(str.charset(), dv, Metadata(&str)); } Item_basic_value(THD *thd): Item(thd) {} + Item_basic_value(): Item() {} public: Field *create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src, @@ -2866,6 +2868,7 @@ class Item_basic_constant :public Item_basic_value { public: Item_basic_constant(THD *thd): Item_basic_value(thd) {}; + Item_basic_constant(): Item_basic_value() {}; bool check_vcol_func_processor(void *arg) { return false; } const Item_const *get_item_const() const { return this; } virtual Item_basic_constant *make_string_literal_concat(THD *thd, @@ -3247,10 +3250,14 @@ class Item_literal: public Item_basic_constant public: Item_literal(THD *thd): Item_basic_constant(thd) { } + Item_literal(): Item_basic_constant() + {} Type type() const override { return CONST_ITEM; } - bool check_partition_func_processor(void *) override { return false;} + bool check_partition_func_processor(void *int_arg) override { return false;} bool const_item() const override { return true; } bool basic_const_item() const override { return true; } + bool is_expensive() override { return false; } + bool cleanup_is_expensive_cache_processor(void *arg) override { return 0; } }; @@ -3258,6 +3265,7 @@ class Item_num: public Item_literal { public: Item_num(THD *thd): Item_literal(thd) { collation= DTCollation_numeric(); } + Item_num(): Item_literal() { collation= DTCollation_numeric(); } Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs) override; bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override { @@ -4236,6 +4244,13 @@ public: name.str= str_arg; name.length= safe_strlen(name.str); unsigned_flag= flag; } + Item_int(const char *str_arg,longlong i,size_t length): + Item_num(), value(i) + { + max_length=(uint32)length; + name.str= str_arg; name.length= safe_strlen(name.str); + unsigned_flag= 1; + } Item_int(THD *thd, const char *str_arg, size_t length=64); const Type_handler *type_handler() const override { return type_handler_long_or_longlong(); } @@ -4270,6 +4285,8 @@ public: Item_bool(THD *thd, const char *str_arg, longlong i): Item_int(thd, str_arg, i, 1) {} Item_bool(THD *thd, bool i) :Item_int(thd, (longlong) i, 1) { } + Item_bool(const char *str_arg, longlong i): + Item_int(str_arg, i, 1) {} bool is_bool_literal() const override { return true; } Item *neg_transformer(THD *thd) override; const Type_handler *type_handler() const override @@ -4286,6 +4303,18 @@ public: }; +class Item_bool_static :public Item_bool +{ +public: + Item_bool_static(const char *str_arg, longlong i): + Item_bool(str_arg, i) {}; + + void set_join_tab_idx(uint join_tab_idx_arg) override + { DBUG_ASSERT(0); } +}; + +extern const Item_bool_static Item_false, Item_true; + class Item_uint :public Item_int { public: |