~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/field.cc

  • Committer: Mark Atwood
  • Date: 2011-07-13 22:28:29 UTC
  • mfrom: (2318.7.25 refactor1)
  • Revision ID: me@mark.atwood.name-20110713222829-sswp061b5ts7tc1k
merge lp:~olafvdspek/drizzle/refactor1

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, table_name, 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, table_name, 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
701
685
  {
702
 
    mark_as_dependent(session, last_checked_context->select_lex,
703
 
                      context->select_lex,
704
 
                      this, (Item_ident*)*reference);
 
686
    mark_as_dependent(session, last_checked_context->select_lex, context->select_lex, this, (Item_ident*)*reference);
705
687
    if (last_checked_context->select_lex->having_fix_field)
706
688
    {
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;
 
689
      Item_ref* rf= new Item_ref(context, (cached_table->getSchemaName()[0] ? cached_table->getSchemaName() : 0), cached_table->alias, field_name);
713
690
      *reference= rf;
714
691
      /*
715
692
        rf is Item_ref => never substitute other items (in this case)
838
815
              Item_field created by the parser with the new Item_ref.
839
816
            */
840
817
            Item_ref *rf= new Item_ref(context, db_name,table_name,field_name);
841
 
            if (!rf)
842
 
              return 1;
843
818
            *reference= rf;
844
819
            /*
845
820
              Because Item_ref never substitutes itself with other items
851
826
        }
852
827
      }
853
828
      if ((ret= fix_outer_field(session, &from_field, reference)) < 0)
854
 
        goto error;
 
829
        return true;
855
830
      outer_fixed= true;
856
831
      if (!ret)
857
832
        goto mark_non_agg_field;
858
833
    }
859
834
    else if (!from_field)
860
 
      goto error;
 
835
      return true;
861
836
 
862
837
    if (!outer_fixed && cached_table && cached_table->select_lex &&
863
838
        context->select_lex &&
865
840
    {
866
841
      int ret;
867
842
      if ((ret= fix_outer_field(session, &from_field, reference)) < 0)
868
 
        goto error;
 
843
        return true;
869
844
      outer_fixed= 1;
870
845
      if (!ret)
871
846
        goto mark_non_agg_field;
923
898
  fixed= 1;
924
899
mark_non_agg_field:
925
900
  return false;
926
 
 
927
 
error:
928
 
  context->process_error(session);
929
 
  return true;
930
901
}
931
902
 
932
903
Item *Item_field::safe_charset_converter(const charset_info_st * const tocs)
946
917
   */
947
918
  field= result_field= 0;
948
919
  null_value= false;
949
 
  return;
950
920
}
951
921
 
952
922
 
976
946
 
977
947
Item_equal *Item_field::find_item_equal(COND_EQUAL *cond_equal)
978
948
{
979
 
  Item_equal *item= 0;
980
949
  while (cond_equal)
981
950
  {
982
951
    List<Item_equal>::iterator li(cond_equal->current_level.begin());
983
 
    while ((item= li++))
 
952
    while (Item_equal* item= li++)
984
953
    {
985
954
      if (item->contains(field))
986
955
        return item;
1211
1180
    popping up.
1212
1181
  */
1213
1182
  Session *session= field->getTable()->in_use;
1214
 
  int no_errors;
1215
 
 
1216
 
  no_errors= session->no_errors;
 
1183
  int no_errors= session->no_errors;
1217
1184
  session->no_errors= 1;
1218
1185
  Item::update_null_value();
1219
1186
  session->no_errors= no_errors;
1252
1219
    List<Item> *all_fields= &select->join->all_fields;
1253
1220
    Item **ref_pointer_array= select->ref_pointer_array;
1254
1221
    int el= all_fields->size();
1255
 
    Item_ref *ref;
1256
 
 
1257
1222
    ref_pointer_array[el]= (Item*)this;
1258
1223
    all_fields->push_front((Item*)this);
1259
 
    ref= new Item_ref(&select->context, ref_pointer_array + el,
1260
 
                      table_name, field_name);
 
1224
    Item_ref* ref= new Item_ref(&select->context, ref_pointer_array + el, table_name, field_name);
1261
1225
    return ref;
1262
1226
  }
1263
1227
  return this;