~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/functions/func.cc

update to latest from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
  set_arguments(list);
57
57
}
58
58
 
59
 
Item_func::Item_func(THD *thd, Item_func *item)
60
 
  :Item_result_field(thd, item),
 
59
Item_func::Item_func(Session *session, Item_func *item)
 
60
  :Item_result_field(session, item),
61
61
   allowed_arg_cols(item->allowed_arg_cols),
62
62
   arg_count(item->arg_count),
63
63
   used_tables_cache(item->used_tables_cache),
70
70
      args= tmp_arg;
71
71
    else
72
72
    {
73
 
      if (!(args=(Item**) thd->alloc(sizeof(Item*)*arg_count)))
 
73
      if (!(args=(Item**) session->alloc(sizeof(Item*)*arg_count)))
74
74
        return;
75
75
    }
76
76
    memcpy(args, item->args, sizeof(Item*)*arg_count);
83
83
 
84
84
  SYNOPSIS:
85
85
  fix_fields()
86
 
  thd    Thread object
 
86
  session    Thread object
87
87
  ref    Pointer to where this object is used.  This reference
88
88
  is used if we want to replace this object with another
89
89
  one (for example in the summary functions).
112
112
*/
113
113
 
114
114
bool
115
 
Item_func::fix_fields(THD *thd, Item **ref __attribute__((unused)))
 
115
Item_func::fix_fields(Session *session, Item **ref __attribute__((unused)))
116
116
{
117
117
  assert(fixed == 0);
118
118
  Item **arg,**arg_end;
119
 
  void *save_thd_marker= thd->thd_marker;
 
119
  void *save_session_marker= session->session_marker;
120
120
  unsigned char buff[STACK_BUFF_ALLOC];      // Max argument in function
121
 
  thd->thd_marker= 0;
 
121
  session->session_marker= 0;
122
122
  used_tables_cache= not_null_tables_cache= 0;
123
123
  const_item_cache=1;
124
124
 
125
 
  if (check_stack_overrun(thd, STACK_MIN_SIZE, buff))
 
125
  if (check_stack_overrun(session, STACK_MIN_SIZE, buff))
126
126
    return true;        // Fatal error if flag is set!
127
127
  if (arg_count)
128
128
  {            // Print purify happy
133
133
        We can't yet set item to *arg as fix_fields may change *arg
134
134
        We shouldn't call fix_fields() twice, so check 'fixed' field first
135
135
      */
136
 
      if ((!(*arg)->fixed && (*arg)->fix_fields(thd, arg)))
 
136
      if ((!(*arg)->fixed && (*arg)->fix_fields(session, arg)))
137
137
        return true;        /* purecov: inspected */
138
138
      item= *arg;
139
139
 
161
161
    }
162
162
  }
163
163
  fix_length_and_dec();
164
 
  if (thd->is_error()) // An error inside fix_length_and_dec occured
 
164
  if (session->is_error()) // An error inside fix_length_and_dec occured
165
165
    return true;
166
166
  fixed= 1;
167
 
  thd->thd_marker= save_thd_marker;
 
167
  session->session_marker= save_session_marker;
168
168
  return false;
169
169
}
170
170
 
264
264
        return 0;
265
265
 
266
266
      /*
267
 
        THD::change_item_tree() should be called only if the tree was
 
267
        Session::change_item_tree() should be called only if the tree was
268
268
        really transformed, i.e. when a new item has been created.
269
269
        Otherwise we'll be allocating a lot of unnecessary memory for
270
270
        change records at each execution.
271
271
      */
272
272
      if (*arg != new_item)
273
 
        current_thd->change_item_tree(arg, new_item);
 
273
        current_session->change_item_tree(arg, new_item);
274
274
    }
275
275
  }
276
276
  return (this->*transformer)(argument);
318
318
      unsigned char *arg_v= *arg_p;
319
319
      Item *new_item= (*arg)->compile(analyzer, &arg_v, transformer, arg_t);
320
320
      if (new_item && *arg != new_item)
321
 
        current_thd->change_item_tree(arg, new_item);
 
321
        current_session->change_item_tree(arg, new_item);
322
322
    }
323
323
  }
324
324
  return (this->*transformer)(arg_t);
328
328
   See comments in Item_cmp_func::split_sum_func()
329
329
*/
330
330
 
331
 
void Item_func::split_sum_func(THD *thd, Item **ref_pointer_array,
 
331
void Item_func::split_sum_func(Session *session, Item **ref_pointer_array,
332
332
                               List<Item> &fields)
333
333
{
334
334
  Item **arg, **arg_end;
335
335
  for (arg= args, arg_end= args+arg_count; arg != arg_end ; arg++)
336
 
    (*arg)->split_sum_func2(thd, ref_pointer_array, fields, arg, true);
 
336
    (*arg)->split_sum_func2(session, ref_pointer_array, fields, arg, true);
337
337
}
338
338
 
339
339