diff options
author | unknown <bell@sanja.is.com.ua> | 2003-09-02 19:56:55 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2003-09-02 19:56:55 +0300 |
commit | 2d7b48987621f20a57487d460d3bd77be4f254d5 (patch) | |
tree | 354683527bb4727d44f35e20a3d4f06e5e53d9b3 /sql/item_cmpfunc.h | |
parent | 0e2f62640500d2d8c0acfbcdc91f207b8457da48 (diff) | |
download | mariadb-git-2d7b48987621f20a57487d460d3bd77be4f254d5.tar.gz |
fixed BUG#1180 (changing WHERE clause of prepared statements by optimisation)
sql/item.h:
constructor and method for aloning AND/OR structure of WHERE clause
sql/item_cmpfunc.cc:
constructor and method for aloning AND/OR structure of WHERE clause
sql/item_cmpfunc.h:
constructor and method for aloning AND/OR structure of WHERE clause
sql/item_func.cc:
constructor for aloning AND/OR structure of WHERE clause
sql/item_func.h:
constructor for aloning AND/OR structure of WHERE clause
sql/sql_lex.cc:
field for saving WHERE root
sql/sql_lex.h:
field for saving WHERE root
sql/sql_prepare.cc:
saving WHERE root
creating new AND/OR structure before executing prepared statement
tests/client_test.c:
test suite for bug #1180
Diffstat (limited to 'sql/item_cmpfunc.h')
-rw-r--r-- | sql/item_cmpfunc.h | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 9379df84199..f8104491978 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -82,6 +82,7 @@ public: Item_bool_func() :Item_int_func() {} Item_bool_func(Item *a) :Item_int_func(a) {} Item_bool_func(Item *a,Item *b) :Item_int_func(a,b) {} + Item_bool_func(THD *thd, Item_bool_func &item) :Item_int_func(thd, item) {} void fix_length_and_dec() { decimals=0; max_length=1; } }; @@ -115,8 +116,8 @@ protected: String tmp_value1,tmp_value2; public: - Item_bool_func2(Item *a,Item *b): - Item_int_func(a,b), cmp(tmp_arg, tmp_arg+1) {} + Item_bool_func2(Item *a,Item *b) + :Item_int_func(a,b), cmp(tmp_arg, tmp_arg+1) {} void fix_length_and_dec(); void set_cmp_func() { @@ -158,7 +159,7 @@ public: class Item_func_eq :public Item_bool_rowready_func2 { public: - Item_func_eq(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}; + Item_func_eq(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {} longlong val_int(); enum Functype functype() const { return EQ_FUNC; } enum Functype rev_functype() const { return EQ_FUNC; } @@ -791,8 +792,13 @@ protected: public: /* Item_cond() is only used to create top level items */ Item_cond() : Item_bool_func(), abort_on_null(1) { const_item_cache=0; } - Item_cond(Item *i1,Item *i2) :Item_bool_func(), abort_on_null(0) - { list.push_back(i1); list.push_back(i2); } + Item_cond(Item *i1,Item *i2) + :Item_bool_func(), abort_on_null(0) + { + list.push_back(i1); + list.push_back(i2); + } + Item_cond(THD *thd, Item_cond &item); ~Item_cond() { list.delete_elements(); } bool add(Item *item) { return list.push_back(item); } bool fix_fields(THD *, struct st_table_list *, Item **ref); @@ -805,6 +811,7 @@ public: void split_sum_func(Item **ref_pointer_array, List<Item> &fields); friend int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds); void top_level_item() { abort_on_null=1; } + void copy_andor_arguments(THD *thd, Item_cond *item); bool walk(Item_processor processor, byte *arg); }; @@ -815,9 +822,17 @@ class Item_cond_and :public Item_cond public: Item_cond_and() :Item_cond() {} Item_cond_and(Item *i1,Item *i2) :Item_cond(i1,i2) {} + Item_cond_and(THD *thd, Item_cond_and &item) :Item_cond(thd, item) {} enum Functype functype() const { return COND_AND_FUNC; } longlong val_int(); const char *func_name() const { return "and"; } + Item* copy_andor_structure(THD *thd) + { + Item_cond_and *item; + if((item= new Item_cond_and(thd, *this))) + item->copy_andor_arguments(thd, this); + return item; + } }; class Item_cond_or :public Item_cond @@ -825,10 +840,18 @@ class Item_cond_or :public Item_cond public: Item_cond_or() :Item_cond() {} Item_cond_or(Item *i1,Item *i2) :Item_cond(i1,i2) {} + Item_cond_or(THD *thd, Item_cond_or &item) :Item_cond(thd, item) {} enum Functype functype() const { return COND_OR_FUNC; } longlong val_int(); const char *func_name() const { return "or"; } table_map not_null_tables() const { return and_tables_cache; } + Item* copy_andor_structure(THD *thd) + { + Item_cond_or *item; + if((item= new Item_cond_or(thd, *this))) + item->copy_andor_arguments(thd, this); + return item; + } }; |