~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/field.cc

  • Committer: Olaf van der Spek
  • Date: 2011-07-05 10:09:23 UTC
  • mto: This revision was merged to the branch mainline in revision 2367.
  • Revision ID: olafvdspek@gmail.com-20110705100923-lvl51f8am1ass9ws
Refactor Items

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
{
59
59
  List<Item_field> *item_list= (List<Item_field>*) arg;
60
60
  List<Item_field>::iterator item_list_it(item_list->begin());
61
 
  Item_field *curr_item;
62
 
  while ((curr_item= item_list_it++))
 
61
  while (Item_field* curr_item= item_list_it++)
63
62
  {
64
63
    if (curr_item->eq(this, 1))
65
64
      return false; /* Already in the set. */
89
88
{
90
89
  KeyPartInfo *first_non_group_part= *((KeyPartInfo **) arg);
91
90
  KeyPartInfo *last_part= *(((KeyPartInfo **) arg) + 1);
92
 
  KeyPartInfo *cur_part;
93
91
 
94
 
  for (cur_part= first_non_group_part; cur_part != last_part; cur_part++)
 
92
  for (KeyPartInfo* cur_part= first_non_group_part; cur_part != last_part; cur_part++)
95
93
  {
96
94
    if (field->eq(cur_part->field))
97
95
      return true;
215
213
{
216
214
  set_field(f);
217
215
  /* 'name' is pointing at field->field_name of old field */
218
 
  name= (char*) f->field_name;
 
216
  name= f->field_name;
219
217
}
220
218
 
221
219
/* ARGSUSED */
324
322
    return false;
325
323
  }
326
324
 
327
 
  switch (result_field->result_type()) {
 
325
  switch (result_field->result_type()) 
 
326
  {
328
327
  case INT_RESULT:
329
328
    return result_field->val_int() != 0;
330
329
 
342
341
    return result_field->val_real() != 0.0;
343
342
 
344
343
  case ROW_RESULT:
345
 
    assert(0);
346
 
    return 0;                                   // Shut up compiler
 
344
    assert(false);
 
345
    return 0;
347
346
  }
348
347
 
349
 
  assert(0);
350
 
  return 0;                                   // Shut up compiler
 
348
  assert(false);
 
349
  return 0;
351
350
}
352
351
 
353
352
 
385
384
    return 0;                                   // const item
386
385
  }
387
386
 
388
 
  return (depended_from ? OUTER_REF_TABLE_BIT : field->getTable()->map);
 
387
  return depended_from ? OUTER_REF_TABLE_BIT : field->getTable()->map;
389
388
}
390
389
 
391
390
enum Item_result Item_field::result_type () const
547
546
              select->group_list.elements &&
548
547
              (place == SELECT_LIST || place == IN_HAVING))
549
548
          {
550
 
            Item_outer_ref *rf;
551
549
            /*
552
550
              If an outer field is resolved in a grouping select then it
553
551
              is replaced for an Item_outer_ref object. Otherwise an
557
555
              after the original field has been fixed and this is done in the
558
556
              fix_inner_refs() function.
559
557
            */
560
 
            ;
561
 
            rf= new Item_outer_ref(context, this);
 
558
            Item_outer_ref* rf= new Item_outer_ref(context, this);
562
559
            *reference= rf;
563
560
            select->inner_refs_list.push_back(rf);
564
561
            rf->in_sum_func= session->lex().in_sum_func;
587
584
        else
588
585
        {
589
586
          Item::Type ref_type= (*reference)->type();
590
 
          prev_subselect_item->used_tables_cache|=
591
 
            (*reference)->used_tables();
592
 
          prev_subselect_item->const_item_cache&=
593
 
            (*reference)->const_item();
 
587
          prev_subselect_item->used_tables_cache|= (*reference)->used_tables();
 
588
          prev_subselect_item->const_item_cache&= (*reference)->const_item();
594
589
          mark_as_dependent(session, last_checked_context->select_lex,
595
 
                            context->select_lex, this,
596
 
                            ((ref_type == REF_ITEM || ref_type == FIELD_ITEM) ?
597
 
                             (Item_ident*) (*reference) :
598
 
                             0));
 
590
            context->select_lex, this, ((ref_type == REF_ITEM || ref_type == FIELD_ITEM) ? (Item_ident*) (*reference) : 0));
599
591
          /*
600
592
            A reference to a view field had been found and we
601
593
            substituted it instead of this Item (find_field_in_tables
653
645
  }
654
646
  else if (ref != not_found_item)
655
647
  {
656
 
    Item *save;
657
 
    Item_ref *rf;
658
 
 
659
648
    /* Should have been checked in resolve_ref_in_select_and_group(). */
660
649
    assert(*ref && (*ref)->fixed);
661
650
    /*
664
653
      constructor, so no initialization is performed, and call
665
654
      fix_fields() below.
666
655
    */
667
 
    save= *ref;
 
656
    Item* save= *ref;
668
657
    *ref= NULL;                             // Don't call set_properties()
669
 
    rf= (place == IN_HAVING ?
670
 
         new Item_ref(context, ref, (char*) table_name,
671
 
                      (char*) field_name, alias_name_used) :
 
658
    Item_ref* rf= (place == IN_HAVING ?
 
659
         new Item_ref(context, ref, (char*) table_name, (char*) field_name, alias_name_used) :
672
660
         (!select->group_list.elements ?
673
 
         new Item_direct_ref(context, ref, (char*) table_name,
674
 
                             (char*) field_name, alias_name_used) :
675
 
         new Item_outer_ref(context, ref, (char*) table_name,
676
 
                            (char*) field_name, alias_name_used)));
 
661
         new Item_direct_ref(context, ref, (char*) table_name, (char*) field_name, alias_name_used) :
 
662
         new Item_outer_ref(context, ref, table_name, field_name, alias_name_used)));
677
663
    *ref= save;
678
664
    if (!rf)
679
665
      return -1;
692
678
    if (rf->fix_fields(session, reference) || rf->check_cols(1))
693
679
      return -1;
694
680
 
695
 
    mark_as_dependent(session, last_checked_context->select_lex,
696
 
                      context->select_lex, this,
697
 
                      rf);
 
681
    mark_as_dependent(session, last_checked_context->select_lex, context->select_lex, this, rf);
698
682
    return 0;
699
683
  }
700
684
  else
704
688
                      this, (Item_ident*)*reference);
705
689
    if (last_checked_context->select_lex->having_fix_field)
706
690
    {
707
 
      Item_ref *rf;
708
 
      rf= new Item_ref(context,
709
 
                       (cached_table->getSchemaName()[0] ? cached_table->getSchemaName() : 0),
710
 
                       (char*) cached_table->alias, (char*) field_name);
711
 
      if (!rf)
712
 
        return -1;
 
691
      Item_ref* rf= new Item_ref(context, (cached_table->getSchemaName()[0] ? cached_table->getSchemaName() : 0), (char*) cached_table->alias, (char*) field_name);
713
692
      *reference= rf;
714
693
      /*
715
694
        rf is Item_ref => never substitute other items (in this case)