~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.cc

  • Committer: Brian Aker
  • Date: 2008-07-28 00:57:12 UTC
  • Revision ID: brian@tangent.org-20080728005712-mkndotf2cvcbp0at
Remove completely ZEROFILL

Show diffs side-by-side

added added

removed removed

Lines of Context:
3786
3786
 
3787
3787
 
3788
3788
/**
3789
 
  Convert a numeric value to a zero-filled string
3790
 
 
3791
 
  @param[in,out]  item   the item to operate on
3792
 
  @param          field  The field that this value is equated to
3793
 
 
3794
 
  This function converts a numeric value to a string. In this conversion
3795
 
  the zero-fill flag of the field is taken into account.
3796
 
  This is required so the resulting string value can be used instead of
3797
 
  the field reference when propagating equalities.
3798
 
*/
3799
 
 
3800
 
static void convert_zerofill_number_to_string(Item **item, Field_num *field)
3801
 
{
3802
 
  char buff[MAX_FIELD_WIDTH],*pos;
3803
 
  String tmp(buff,sizeof(buff), field->charset()), *res;
3804
 
 
3805
 
  res= (*item)->val_str(&tmp);
3806
 
  field->prepend_zeros(res);
3807
 
  pos= (char *) sql_strmake (res->ptr(), res->length());
3808
 
  *item= new Item_string(pos, res->length(), field->charset());
3809
 
}
3810
 
 
3811
 
 
3812
 
/**
3813
3789
  Set a pointer to the multiple equality the field reference belongs to
3814
3790
  (if any).
3815
3791
 
3855
3831
  if (!item ||
3856
3832
      (cmp_context != (Item_result)-1 && item->cmp_context != cmp_context))
3857
3833
    item= this;
3858
 
  else if (field && (field->flags & ZEROFILL_FLAG) && IS_NUM(field->type()))
3859
 
  {
3860
 
    if (item && cmp_context != INT_RESULT)
3861
 
      convert_zerofill_number_to_string(&item, (Field_num *)field);
3862
 
    else
3863
 
      item= this;
3864
 
  }
 
3834
 
3865
3835
  return item;
3866
3836
}
3867
3837