~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/field.cc

edit

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
 
20
#include "config.h"
21
21
 
22
22
#include <drizzled/session.h>
23
23
#include <drizzled/table.h>
56
56
bool Item_field::collect_item_field_processor(unsigned char *arg)
57
57
{
58
58
  List<Item_field> *item_list= (List<Item_field>*) arg;
59
 
  List<Item_field>::iterator item_list_it(item_list->begin());
 
59
  List_iterator<Item_field> item_list_it(*item_list);
60
60
  Item_field *curr_item;
61
61
  while ((curr_item= item_list_it++))
62
62
  {
165
165
   have_privileges(0),
166
166
   any_privileges(0)
167
167
{
168
 
  Select_Lex *select= getSession().getLex()->current_select;
 
168
  Select_Lex *select= current_session->lex->current_select;
169
169
  collation.set(DERIVATION_IMPLICIT);
170
170
 
171
171
  if (select && select->parsing_place != IN_HAVING)
262
262
  return result_field->val_str(str,&str_value);
263
263
}
264
264
 
265
 
bool Item_field::get_date(type::Time &ltime,uint32_t fuzzydate)
 
265
bool Item_field::get_date(type::Time *ltime,uint32_t fuzzydate)
266
266
{
267
267
  if ((null_value=field->is_null()) || field->get_date(ltime,fuzzydate))
268
268
  {
269
 
    ltime.reset();
 
269
    memset(ltime, 0, sizeof(*ltime));
270
270
    return 1;
271
271
  }
272
272
  return 0;
273
273
}
274
274
 
275
 
bool Item_field::get_date_result(type::Time &ltime,uint32_t fuzzydate)
 
275
bool Item_field::get_date_result(type::Time *ltime,uint32_t fuzzydate)
276
276
{
277
277
  if ((null_value=result_field->is_null()) ||
278
278
      result_field->get_date(ltime,fuzzydate))
279
279
  {
280
 
    ltime.reset();
 
280
    memset(ltime, 0, sizeof(*ltime));
281
281
    return 1;
282
282
  }
283
283
  return 0;
284
284
}
285
285
 
286
 
bool Item_field::get_time(type::Time &ltime)
 
286
bool Item_field::get_time(type::Time *ltime)
287
287
{
288
288
  if ((null_value=field->is_null()) || field->get_time(ltime))
289
289
  {
290
 
    ltime.reset();
 
290
    memset(ltime, 0, sizeof(*ltime));
291
291
    return 1;
292
292
  }
293
293
  return 0;
332
332
      type::Decimal decimal_value;
333
333
      type::Decimal *val= result_field->val_decimal(&decimal_value);
334
334
      if (val)
335
 
        return not val->isZero();
 
335
        return not val->is_zero();
336
336
      return 0;
337
337
    }
338
338
 
496
496
  */
497
497
  Name_resolution_context *last_checked_context= context;
498
498
  Item **ref= (Item **) not_found_item;
499
 
  Select_Lex *current_sel= (Select_Lex *) session->getLex()->current_select;
 
499
  Select_Lex *current_sel= (Select_Lex *) session->lex->current_select;
500
500
  Name_resolution_context *outer_context= 0;
501
501
  Select_Lex *select= 0;
502
502
  /* Currently derived tables cannot be correlated */
562
562
              return -1;
563
563
            session->change_item_tree(reference, rf);
564
564
            select->inner_refs_list.push_back(rf);
565
 
            rf->in_sum_func= session->getLex()->in_sum_func;
 
565
            rf->in_sum_func= session->lex->in_sum_func;
566
566
          }
567
567
          /*
568
568
            A reference is resolved to a nest level that's outer or the same as
569
569
            the nest level of the enclosing set function : adjust the value of
570
570
            max_arg_level for the function if it's needed.
571
571
          */
572
 
          if (session->getLex()->in_sum_func &&
573
 
              session->getLex()->in_sum_func->nest_level >= select->nest_level)
 
572
          if (session->lex->in_sum_func &&
 
573
              session->lex->in_sum_func->nest_level >= select->nest_level)
574
574
          {
575
575
            Item::Type ref_type= (*reference)->type();
576
 
            set_if_bigger(session->getLex()->in_sum_func->max_arg_level,
 
576
            set_if_bigger(session->lex->in_sum_func->max_arg_level,
577
577
                          select->nest_level);
578
578
            set_field(*from_field);
579
579
            fixed= 1;
640
640
    if (upward_lookup)
641
641
    {
642
642
      // We can't say exactly what absent table or field
643
 
      my_error(ER_BAD_FIELD_ERROR, MYF(0), full_name(), session->where());
 
643
      my_error(ER_BAD_FIELD_ERROR, MYF(0), full_name(), session->where);
644
644
    }
645
645
    else
646
646
    {
682
682
    if (place != IN_HAVING && select->group_list.elements)
683
683
    {
684
684
      outer_context->select_lex->inner_refs_list.push_back((Item_outer_ref*)rf);
685
 
      ((Item_outer_ref*)rf)->in_sum_func= session->getLex()->in_sum_func;
 
685
      ((Item_outer_ref*)rf)->in_sum_func= session->lex->in_sum_func;
686
686
    }
687
687
    session->change_item_tree(reference, rf);
688
688
    /*
788
788
                                          context->first_name_resolution_table,
789
789
                                          context->last_name_resolution_table,
790
790
                                          reference,
791
 
                                          session->getLex()->use_only_table_context ?
 
791
                                          session->lex->use_only_table_context ?
792
792
                                            REPORT_ALL_ERRORS :
793
793
                                            IGNORE_EXCEPT_NON_UNIQUE, true)) ==
794
794
        not_found_field)
795
795
    {
796
796
      int ret;
797
797
      /* Look up in current select's item_list to find aliased fields */
798
 
      if (session->getLex()->current_select->is_item_list_lookup)
 
798
      if (session->lex->current_select->is_item_list_lookup)
799
799
      {
800
800
        uint32_t counter;
801
801
        enum_resolution_type resolution;
802
802
        Item** res= find_item_in_list(session,
803
 
                                      this, session->getLex()->current_select->item_list,
 
803
                                      this, session->lex->current_select->item_list,
804
804
                                      &counter, REPORT_EXCEPT_NOT_FOUND,
805
805
                                      &resolution);
806
806
        if (!res)
824
824
            {
825
825
              /* The column to which we link isn't valid. */
826
826
              my_error(ER_BAD_FIELD_ERROR, MYF(0), (*res)->name,
827
 
                       session->where());
 
827
                       current_session->where);
828
828
              return(1);
829
829
            }
830
830
 
888
888
      return false;
889
889
 
890
890
    set_field(from_field);
891
 
    if (session->getLex()->in_sum_func &&
892
 
        session->getLex()->in_sum_func->nest_level ==
893
 
        session->getLex()->current_select->nest_level)
 
891
    if (session->lex->in_sum_func &&
 
892
        session->lex->in_sum_func->nest_level ==
 
893
        session->lex->current_select->nest_level)
894
894
    {
895
 
      set_if_bigger(session->getLex()->in_sum_func->max_arg_level,
896
 
                    session->getLex()->current_select->nest_level);
 
895
      set_if_bigger(session->lex->in_sum_func->max_arg_level,
 
896
                    session->lex->current_select->nest_level);
897
897
    }
898
898
  }
899
899
  else if (session->mark_used_columns != MARK_COLUMNS_NONE)
980
980
  Item_equal *item= 0;
981
981
  while (cond_equal)
982
982
  {
983
 
    List<Item_equal>::iterator li(cond_equal->current_level.begin());
 
983
    List_iterator_fast<Item_equal> li(cond_equal->current_level);
984
984
    while ((item= li++))
985
985
    {
986
986
      if (item->contains(field))