diff options
author | unknown <bell@sanja.is.com.ua> | 2004-10-09 01:01:19 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-10-09 01:01:19 +0300 |
commit | c6b382d63b245352843ffe37977e3106daad5879 (patch) | |
tree | c4a132c49116c629c762d7542fc01417bf89e9ee /sql | |
parent | 166d19e9638595cd56cdfb1d65dbebdd64e6013d (diff) | |
download | mariadb-git-c6b382d63b245352843ffe37977e3106daad5879.tar.gz |
args_copy and cleunup() removed from Item_sum
registration changing ITEM_SUM arguments added
sql/item.cc:
cleunup for Item_result_field
sql/item.h:
cleunup for Item_result_field
sql/item_sum.cc:
args_copy and cleunup() removed from Item_sum
sql/item_sum.h:
args_copy and cleunup() removed from Item_sum
sql/sql_select.cc:
registration changing ITEM_SUM arguments
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.cc | 8 | ||||
-rw-r--r-- | sql/item.h | 1 | ||||
-rw-r--r-- | sql/item_sum.cc | 55 | ||||
-rw-r--r-- | sql/item_sum.h | 10 | ||||
-rw-r--r-- | sql/sql_select.cc | 8 |
5 files changed, 18 insertions, 64 deletions
diff --git a/sql/item.cc b/sql/item.cc index 564bc72927c..067e5d91084 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2629,6 +2629,14 @@ String *Item_type_holder::val_str(String*) return 0; } +void Item_result_field::cleanup() +{ + DBUG_ENTER("Item_result_field::cleanup()"); + Item::cleanup(); + result_field= 0; + DBUG_VOID_RETURN; +} + /***************************************************************************** ** Instantiate templates *****************************************************************************/ diff --git a/sql/item.h b/sql/item.h index 589edb88565..ff229a04c68 100644 --- a/sql/item.h +++ b/sql/item.h @@ -774,6 +774,7 @@ public: { save_in_field(result_field, no_conversions); } + void cleanup(); }; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 290e10bd59a..facd504b5fb 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -24,7 +24,7 @@ #include "mysql_priv.h" Item_sum::Item_sum(List<Item> &list) - :args_copy(0), arg_count(list.elements) + :arg_count(list.elements) { if ((args=(Item**) sql_alloc(sizeof(Item*)*arg_count))) { @@ -56,39 +56,6 @@ Item_sum::Item_sum(THD *thd, Item_sum *item): if (!(args= (Item**) thd->alloc(sizeof(Item*)*arg_count))) return; memcpy(args, item->args, sizeof(Item*)*arg_count); - if (item->args_copy != 0) - save_args(thd); - else - args_copy= 0; -} - - -/* - Save copy of arguments if we prepare prepared statement - (arguments can be rewritten in get_tmp_table_item()) - - SYNOPSIS - Item_sum::save_args_for_prepared_statement() - thd - thread handler - - RETURN - 0 - OK - 1 - Error -*/ -bool Item_sum::save_args_for_prepared_statement(THD *thd) -{ - if (thd->current_arena->is_stmt_prepare()) - return save_args(thd->current_arena); - return 0; -} - - -bool Item_sum::save_args(Item_arena* arena) -{ - if (!(args_copy= (Item**) arena->alloc(sizeof(Item*)*arg_count))) - return 1; - memcpy(args_copy, args, sizeof(Item*)*arg_count); - return 0; } @@ -99,17 +66,6 @@ void Item_sum::mark_as_sum_func() } -void Item_sum::cleanup() -{ - DBUG_ENTER("Item_sum::cleanup"); - Item_result_field::cleanup(); - if (args_copy != 0) - memcpy(args, args_copy, sizeof(Item*)*arg_count); - result_field=0; - DBUG_VOID_RETURN; -} - - void Item_sum::make_field(Send_field *tmp_field) { if (args[0]->type() == Item::FIELD_ITEM && keep_field_type()) @@ -214,9 +170,6 @@ Item_sum_num::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) { DBUG_ASSERT(fixed == 0); - if (save_args_for_prepared_statement(thd)) - return 1; - if (!thd->allow_sum_func) { my_error(ER_INVALID_GROUP_FUNC_USE,MYF(0)); @@ -248,9 +201,6 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) { DBUG_ASSERT(fixed == 0); - if (save_args_for_prepared_statement(thd)) - return 1; - Item *item= args[0]; if (!thd->allow_sum_func) { @@ -1948,9 +1898,6 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) uint i; /* for loop variable */ DBUG_ASSERT(fixed == 0); - if (save_args_for_prepared_statement(thd)) - return 1; - if (!thd->allow_sum_func) { my_error(ER_INVALID_GROUP_FUNC_USE,MYF(0)); diff --git a/sql/item_sum.h b/sql/item_sum.h index 5081d592654..2e85ba87468 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -33,23 +33,22 @@ public: }; Item **args, *tmp_args[2]; - Item **args_copy; /* copy of arguments for PS */ uint arg_count; bool quick_group; /* If incremental update of fields */ void mark_as_sum_func(); - Item_sum() :args_copy(0), arg_count(0), quick_group(1) + Item_sum() :arg_count(0), quick_group(1) { mark_as_sum_func(); } Item_sum(Item *a) - :args(tmp_args), args_copy(0), arg_count(1), quick_group(1) + :args(tmp_args), arg_count(1), quick_group(1) { args[0]=a; mark_as_sum_func(); } Item_sum( Item *a, Item *b ) - :args(tmp_args), args_copy(0), arg_count(2), quick_group(1) + :args(tmp_args), arg_count(2), quick_group(1) { args[0]=a; args[1]=b; mark_as_sum_func(); @@ -57,7 +56,6 @@ public: Item_sum(List<Item> &list); //Copy constructor, need to perform subselects with temporary tables Item_sum(THD *thd, Item_sum *item); - void cleanup(); enum Type type() const { return SUM_FUNC_ITEM; } virtual enum Sumfunctype sum_func () const=0; inline bool reset() { clear(); return add(); }; @@ -92,8 +90,6 @@ public: virtual bool setup(THD *thd) {return 0;} virtual void make_unique() {} Item *get_tmp_table_item(THD *thd); - bool save_args_for_prepared_statement(THD *); - bool save_args(Item_arena *arena); bool walk (Item_processor processor, byte *argument); }; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0834f0659da..e7316e89087 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4940,7 +4940,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ((Item_sum*) item)->result_field=0; for (i=0 ; i < ((Item_sum*) item)->arg_count ; i++) { - Item *arg= ((Item_sum*) item)->args[i]; + Item **argp= ((Item_sum*) item)->args + i; + Item *arg= *argp; if (!arg->const_item()) { Field *new_field= @@ -4956,7 +4957,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, *blob_field++= new_field; blob_count++; } - ((Item_sum*) item)->args[i]= new Item_field(new_field); + thd->register_item_tree_change(argp, arg, &thd->mem_root); + *argp= new Item_field(new_field); if (!(new_field->flags & NOT_NULL_FLAG)) { null_count++; @@ -4964,7 +4966,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, new_field->maybe_null() is still false, it will be changed below. But we have to setup Item_field correctly */ - ((Item_sum*) item)->args[i]->maybe_null=1; + (*argp)->maybe_null=1; } } } |