~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/sql_select.cc

  • Committer: Brian Aker
  • Date: 2008-07-05 19:24:24 UTC
  • mfrom: (53.2.8 codestyle)
  • Revision ID: brian@tangent.org-20080705192424-3uslywtteymm7xqy
First pass of removing BIT_TYPE

Show diffs side-by-side

added added

removed removed

Lines of Context:
681
681
      fix_inner_refs(thd, all_fields, select_lex, ref_pointer_array))
682
682
    DBUG_RETURN(-1);
683
683
 
684
 
  if (group_list)
685
 
  {
686
 
    /*
687
 
      Because HEAP tables can't index BIT fields we need to use an
688
 
      additional hidden field for grouping because later it will be
689
 
      converted to a LONG field. Original field will remain of the
690
 
      BIT type and will be returned to a client.
691
 
    */
692
 
    for (ORDER *ord= group_list; ord; ord= ord->next)
693
 
    {
694
 
      if ((*ord->item)->type() == Item::FIELD_ITEM &&
695
 
          (*ord->item)->field_type() == MYSQL_TYPE_BIT)
696
 
      {
697
 
        Item_field *field= new Item_field(thd, *(Item_field**)ord->item);
698
 
        int el= all_fields.elements;
699
 
        ref_pointer_array[el]= field;
700
 
        all_fields.push_front(field);
701
 
        ord->item= ref_pointer_array + el;
702
 
      }
703
 
    }
704
 
  }
705
 
 
706
684
  /*
707
685
    Check if there are references to un-aggregated columns when computing 
708
686
    aggregate functions with implicit grouping (there is no GROUP BY).
11040
11018
      if (result && modify_item)
11041
11019
        field->result_field= result;
11042
11020
    } 
11043
 
    else if (table_cant_handle_bit_fields && field->field->type() ==
11044
 
             MYSQL_TYPE_BIT)
11045
 
    {
11046
 
      *from_field= field->field;
11047
 
      result= create_tmp_field_from_item(thd, item, table, copy_func,
11048
 
                                        modify_item, convert_blob_length);
11049
 
      if (result && modify_item)
11050
 
        field->result_field= result;
11051
 
    }
11052
11021
    else
11053
11022
      result= create_tmp_field_from_field(thd, (*from_field= field->field),
11054
11023
                                          orig_item ? orig_item->name :
11370
11339
            *blob_field++= fieldnr;
11371
11340
            blob_count++;
11372
11341
          }
11373
 
          if (new_field->type() == MYSQL_TYPE_BIT)
11374
 
            total_uneven_bit_length+= new_field->field_length & 7;
11375
11342
          *(reg_field++)= new_field;
11376
11343
          if (new_field->real_type() == MYSQL_TYPE_STRING ||
11377
11344
              new_field->real_type() == MYSQL_TYPE_VARCHAR)
11437
11404
      reclength+=new_field->pack_length();
11438
11405
      if (!(new_field->flags & NOT_NULL_FLAG))
11439
11406
        null_count++;
11440
 
      if (new_field->type() == MYSQL_TYPE_BIT)
11441
 
        total_uneven_bit_length+= new_field->field_length & 7;
11442
11407
      if (new_field->flags & BLOB_FLAG)
11443
11408
      {
11444
11409
        *blob_field++= fieldnr;
11583
11548
    }
11584
11549
    else
11585
11550
      field->move_field(pos,(uchar*) 0,0);
11586
 
    if (field->type() == MYSQL_TYPE_BIT)
11587
 
    {
11588
 
      /* We have to reserve place for extra bits among null bits */
11589
 
      ((Field_bit*) field)->set_bit_ptr(null_flags + null_count / 8,
11590
 
                                        null_count & 7);
11591
 
      null_count+= (field->field_length & 7);
11592
 
    }
11593
11551
    field->reset();
11594
11552
 
11595
11553
    /*
16619
16577
      if (!ord)
16620
16578
        return 0;
16621
16579
 
16622
 
      if (item->type() == Item::FIELD_ITEM &&
16623
 
          item->field_type() == MYSQL_TYPE_BIT)
16624
 
      {
16625
 
        /*
16626
 
          Because HEAP tables can't index BIT fields we need to use an
16627
 
          additional hidden field for grouping because later it will be
16628
 
          converted to a LONG field. Original field will remain of the
16629
 
          BIT type and will be returned to a client.
16630
 
        */
16631
 
        Item_field *new_item= new Item_field(thd, (Item_field*)item);
16632
 
        int el= all_fields.elements;
16633
 
        orig_ref_pointer_array[el]= new_item;
16634
 
        all_fields.push_front(new_item);
16635
 
        ord->item= orig_ref_pointer_array + el;
16636
 
      }
16637
 
      else
16638
 
      {
16639
 
        /*
16640
 
          We have here only field_list (not all_field_list), so we can use
16641
 
          simple indexing of ref_pointer_array (order in the array and in the
16642
 
          list are same)
16643
 
        */
16644
 
        ord->item= ref_pointer_array;
16645
 
      }
 
16580
      /*
 
16581
        We have here only field_list (not all_field_list), so we can use
 
16582
        simple indexing of ref_pointer_array (order in the array and in the
 
16583
        list are same)
 
16584
      */
 
16585
      ord->item= ref_pointer_array;
16646
16586
      ord->asc=1;
16647
16587
      *prev=ord;
16648
16588
      prev= &ord->next;
16782
16722
        key_length+=MAX_BLOB_WIDTH;             // Can't be used as a key
16783
16723
      else if (type == MYSQL_TYPE_VARCHAR || type == MYSQL_TYPE_VAR_STRING)
16784
16724
        key_length+= field->field_length + HA_KEY_BLOB_LENGTH;
16785
 
      else if (type == MYSQL_TYPE_BIT)
16786
 
      {
16787
 
        /* Bit is usually stored as a longlong key for group fields */
16788
 
        key_length+= 8;                         // Big enough
16789
 
      }
16790
16725
      else
16791
16726
        key_length+= field->pack_length();
16792
16727
    }