From 9a6691965bfbbd3689d2d0355d12cd6a92ebb5ad Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 May 2002 19:08:56 +0300 Subject: Fix for ISNULL() Docs/manual.texi: Chagnelog mysql-test/r/join.result: New tests for IS NULL mysql-test/t/join.test: New tests for IS NULL --- sql/item_cmpfunc.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sql/item_cmpfunc.h') diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 5ee0687c064..e7c598808e8 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -429,6 +429,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(); @@ -449,6 +450,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; } }; -- cgit v1.2.1 From 1503a4724e9bd65826cf7547240c4e03f773d2a0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 May 2002 16:45:00 +0300 Subject: Optimize LIKE with turbo-boyer-more algoritm Docs/manual.texi: Added info about LIKE optimization mysql-test/r/func_like.result: Test of new LIKE optimization mysql-test/t/func_like.test: Test of new LIKE optimization --- sql/item_cmpfunc.h | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'sql/item_cmpfunc.h') diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 2048c4baea8..cd6e3d6e414 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -478,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 -- cgit v1.2.1