diff options
Diffstat (limited to 'sql/item_cmpfunc.h')
-rw-r--r-- | sql/item_cmpfunc.h | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 350e369eaac..ea5f4a6b0bf 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -430,6 +430,7 @@ class Item_func_in :public Item_int_func class Item_func_isnull :public Item_bool_func { + longlong cached_value; public: Item_func_isnull(Item *a) :Item_bool_func(a) {} longlong val_int(); @@ -450,6 +451,12 @@ public: args[0]->update_used_tables(); used_tables_cache=args[0]->used_tables(); } + if (!used_tables_cache) + { + /* Remember if the value is always NULL or never NULL */ + args[0]->val(); + cached_value= args[0]->null_value ? (longlong) 1 : (longlong) 0; + } } optimize_type select_optimize() const { return OPTIMIZE_NULL; } }; @@ -471,15 +478,40 @@ public: class Item_func_like :public Item_bool_func2 { char escape; -public: - Item_func_like(Item *a,Item *b, char* escape_arg) :Item_bool_func2(a,b),escape(*escape_arg) + + // Turbo Boyer-Moore data + bool canDoTurboBM; // pattern is '%abcd%' case + const char* pattern; + int pattern_len; + + // TurboBM buffers, *this is owner + int* bmGs; // good suffix shift table, size is pattern_len + 1 + int* bmBc; // bad character shift table, size is alphabet_size + + void turboBM_compute_suffixes(int* suff); + void turboBM_compute_good_suffix_shifts(int* suff); + void turboBM_compute_bad_character_shifts(); + bool turboBM_matches(const char* text, int text_len) const; + enum { alphabet_size = 256 }; + +public: + Item_func_like::Item_func_like(Item *a,Item *b, char* escape_arg) : + Item_bool_func2(a,b), + escape(*escape_arg), + canDoTurboBM(false), + pattern(0), + pattern_len(0), + bmGs(0), + bmBc(0) {} + longlong val_int(); enum Functype functype() const { return LIKE_FUNC; } optimize_type select_optimize() const; cond_result eq_cmp_result() const { return COND_TRUE; } const char *func_name() const { return "like"; } void fix_length_and_dec(); + bool fix_fields(THD *thd,struct st_table_list *tlist); }; #ifdef USE_REGEX |