mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
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
This commit is contained in:
parent
166d19e963
commit
c6b382d63b
5 changed files with 18 additions and 64 deletions
|
@ -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
|
||||
*****************************************************************************/
|
||||
|
|
|
@ -774,6 +774,7 @@ public:
|
|||
{
|
||||
save_in_field(result_field, no_conversions);
|
||||
}
|
||||
void cleanup();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue